5
I am using Curl php on the server.
function getSite($url){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
echo curl_error($ch);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
}
getSite("http://www.google.com");
getSite("http://www.planalto.gov.br/ccivil_03/Constituicao/Constituicao.htm");
The google site works perfectly but the plateau site does not. In localhost the 2 work. What could be going on? The 2 sites are external but only one works (the site link of the plateau is correct but neither Curl error shows ) thank you in advance
Test add more curl_setopt, at least the basic one. Ignore SSL/CA, using
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
andcurl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0)
, add to follow redirect usingcurl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1)
, add a USER_AGENT, using, for example:curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
. If this solves I can explain it better in an answer. THIS IS FOR TEST! If this does not solve the IP may be blocked, or external factor,– Inkeliz
is giving the following error with the items you requested to add
– Vagner Gonçalves Gonçalves
is giving the following error with the items you requested to add CURLOPT_FOLOWLOCATION cannot be Activated when an open_basedir is set . Removing the CURLOPT_FOLLOWLOCATION remains the same ,I’m guessing my hosting server is blocking the site from the plateau. That is possible?
– Vagner Gonçalves Gonçalves