我需要使用 curl 从 Facebook 获取用户提要,我已经通过 curl 发送请求并得到了
Facebook returned HTTP Error Code: 404 error, follow is my code to connect facebook through curl
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_ENCODING , 'gzip, deflate');
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_USERAGENT, "php-facebook-wall (https://github.com/dordotky/php-facebook-wall)");
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, $url = "https://graph.facebook.com/".FACEBOOK_USER_NAME
."/".FACEBOOK_USER_OBJECT."?access_token=".FACEBOOK_APP_ID."|".FACEBOOK_APP_SECRET);
// Execute our curl request
$result = curl_exec($curl);
// Check that we didn't encounter any errors while processing
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ((!curl_error($curl)) && ($http_code == 200))
{
$json = json_decode($result, true);
} else
{
die("Facebook returned HTTP Error Code: ".$http_code);
}
?>