我正使用 CURL 访问Facebook页面。 本地操作完美, 但当我上传到 Dev 服务器时, 它会折断并返回一个空字符串。 我检查过, 并在服务器上安装了 CURL 。 这里是用于访问Facebook的代码 :
$header = array();
$header[] = Accept: text/json ;
$header[] = Cache-Control: max-age=0 ;
$header[] = Connection: keep-alive ;
$header[] = Keep-Alive: 300 ;
$header[] = Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 ;
$header[] = Accept-Language: en-us,en;q=0.5 ;
$header[] = Pragma: ;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, http://facebook.com/feeds/page.php?format=json&id=135137236003 );
curl_setopt($ch, CURLOPT_USERAGENT, Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729) );
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_ENCODING, );
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close ($ch);
任何帮助都感激不尽!