PinoyStackOverflower
PinoyStackOverflower

Reputation: 5302

Facebook FQL getting status does not work and returns empty list

I just followed the sample in here https://developers.facebook.com/docs/reference/fql/ , but I replaced the query with like this https://developers.facebook.com/docs/reference/fql/status/ but I replaced the uid with me()

So here's my code:

 $token_url = 'https://graph.facebook.com/oauth/access_token?client_id='
            . $app_id . '&redirect_uri=' . urlencode($my_url) 
            . '&client_secret=' . $app_secret 
            . '&code=' . $code;

$access_token = file_get_contents($token_url);

$q = urlencode("SELECT status_id, message FROM status WHERE uid=me()");

$fql_query_url = 'https://graph.facebook.com/'
        . '/fql?q='.$q
        . '&' . $access_token;
$fql_query_result = file_get_contents($fql_query_url);
$fql_query_obj = json_decode($fql_query_result, true);

echo '<pre>';
print_r("query results:");
print_r($fql_query_obj);
echo '</pre>';

This one does not return anything. It just gives me an empty array.

enter image description here

This is already the permission of my app: enter image description here

I don't know what's the problem in here anymore. I'm sure that my app Id and secret key are correct.

What's wrong with this code? i'm getting an empty list. It's not fetching my status updates. Your help would be greatly appreciated and rewarded!

Thanks!

Upvotes: 0

Views: 608

Answers (2)

air_bob
air_bob

Reputation: 1337

Encounter same problem here, to make sure the user have granted "read stream" permission, here is what I did:

  $params = array(
  'scope' => 'read_stream'
  );
  $loginUrl = $facebook->getLoginUrl($params);

Upvotes: 0

phwd
phwd

Reputation: 19995

That permission is just for the settings. It doesn't signify whether each individual user has granted permissions.

Try /me/permissions?fields=read_stream on the user with the correct access token to see whether the user has given permission.

You should get

{
  "data": [
    {
      "read_stream": 1
    }
  ]
}

Once you are sure that is set then it should work. A quick way to check would be try it in the Graph Explorer against your access token

https://developers.facebook.com/tools/explorer?fql=SELECT%20status_id%2C%20message%20FROM%20status%20WHERE%20uid%3Dme()

Upvotes: 3

Related Questions