开发者

cURL on PHP 5.1.4 not returning anything from xml feed

开发者 https://www.devze.com 2023-03-23 05:56 出处:网络
I am trying to get the code below working on a server running PHP 5.1.4 but it does not appear to be returning anything; pri开发者_运维知识库nt_r($buffer); displays nothing and var_dump($buffer); retu

I am trying to get the code below working on a server running PHP 5.1.4 but it does not appear to be returning anything; pri开发者_运维知识库nt_r($buffer); displays nothing and var_dump($buffer); returns "bool(false)". It works on servers running PHP 5.2.x and 5.3.2 though..

 error_reporting(E_ALL);
 $ch = curl_init("http://api.twitter.com/1/statuses/user_timeline/xxxxxxxxxxxxxx.xml");
 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
 curl_setopt($ch, CURLOPT_POST, FALSE);
 $buffer = curl_exec($ch);
 curl_close($ch);
 print_r($buffer);
 var_dump($buffer);


curl_exec returns boolean FALSE when an error occurs. Try doing:

$buffer = curl_exec($ch);
if ($buffer === FALSE) {
    die(curl_error($ch));
}

which'll spit out the error message/code for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消