Why doesn't CURL always work?
Posted: Wed Jun 22, 2005 1:08 pm
I'm using CURL functions in some of my scripts. For the most part, they work great - but once in a while, it will return an error for a perfectly good url. My (relevant) code is:
Almost always works, but for example for this url: http://www.ch2bc.org/
it always returns false (for both $page and $status), whereas the page in question loads quickly into my browser, and doesn't seem to have any funny business. What am I doing wrong?
Code: Select all
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)");
curl_setopt($ch,CURLOPT_TIMEOUT,10);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_URL,$url);
$page=curl_exec($ch);
$status=curl_getinfo($ch,CURLINFO_HTTP_CODE);it always returns false (for both $page and $status), whereas the page in question loads quickly into my browser, and doesn't seem to have any funny business. What am I doing wrong?