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.
精彩评论