Question

I was using this code for the past year and a half to successfully pull the facebook pages that a user was an administrator of ( after being granted rights ) to allow them to select which page they wanted to post some content to. However, it recently started returning an empty array ( instead of an array of results ) - has FQL or the PHP Rest SDK stopped working?

require_once('path/to/facebook/php-sdk/src/facebook.php');

$facebook = new Facebook(array(
  'appId'  => 'myAppId',
  'secret' => 'myAppSecret',
  'cookie' => true,
));

$session = $facebook->getSession();

$me = null;

// Session based API call.
if ($session) {
    try {
        $uid = $facebook->getUser();
        $me = $facebook->api('/me');
    } catch (FacebookApiException $e) {
        error_log($e);
        die(var_dump($e));
    }
}

if ($me) {
    $pages = $facebook->api(array(
        'method'    =>  'fql.query',
        'query'     =>  'SELECT page_id,name,pic_square,pic_small FROM page WHERE page_id IN ( SELECT page_id FROM page_admin WHERE uid = "'.$me['id'].'" )'
    ));

}

// $pages is an empty array at this point, but used to be an array representing the FQL results for that query.
Was it helpful?

Solution

in the past year and a half facebook has changed the way we interact with them. The SDK's have changed and the methods used in them have changed slightly too. You should review your code and make sure it is in sync with the new specifications.
here is a link to the documentation on the PHP SDK.

Further more the REST API has been deprecated

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top