我没有在代码库中更改此代码250天,Facebook Graph API返回400 Error
。它是一个小的PHP服务,返回给定用户的最新推文。
$appID = '**********';
$appSecret = '***********';
$feed = $_GET['username']; // PAGE ID
$maximum = $_GET['numposts']; // NUMBER OF POSTS
$authentication = file_get_contents("https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id={$appID}&client_secret={$appSecret}");
$response = file_get_contents("https://graph.facebook.com/{$feed}/posts?{$authentication}&limit={$maximum}&format=json&fields=id,message,created_time,link,full_picture,shares");
// ACCESS CONTROL
header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
// CACHE
$seconds_to_cache = 225; // 3 MINS
$ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
header("Expires: $ts");
header("Pragma: cache");
header("Cache-Control: max-age=$seconds_to_cache");
header('Content-Type: application/json; charset=UTF-8');
echo $response;
,返回的错误是
failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
有两种思路:
我尝试重新生成令牌并进行更新,但没有运气。