I haven't changed this code in our code base for 250 days and the Facebook Graph API is returning a 400 Error
. Its a small php service that returns the latest tweets of a given user.
$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;
and the error returned is
failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
There are two trails of thought:
- We're over the limit on our requests.
- Facebook Graph API have changed their endpoint (although no information from there).
I have tried regenerating the tokens and updating but with no luck.