Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Graph API Returning Empty Data Set

I am attempting to use the Graph API Explorer to create an access token for my application to view my pages using 'me/accounts'. However, every time I try this, it returns me an empty data set. I have chosen manage_pages as a permission and it still doesn't work. Without checking any other permissions, I am able to view 'me/likes', 'me/movies', etc.. I have no idea what I am doing wrong.

This is what I'm doing:

https://developers.facebook.com/tools/explorer/

  1. Select my application from the drop-down menu.
  2. Click "Get Access Token" >> Check "manage_pages" >> Get Access Token
  3. Submit "GET /me/accounts"

I get :

{
  "data": [
  ]
}

I have been through a dozen different google searches for an answer to my problem and have tried everything, including creating user tokens and app tokens. Any help would be much appreciated. Thanks!

UPDATE 6/27/13 I found a couple of resources that say to include publish_stream as a permission as well, which I tried. Still no success tho. Also, somebody had suggested that it might be a restrictions problem, but my app has no restrictions(except the default 13+).

like image 946
user1770011 Avatar asked Jun 26 '13 20:06

user1770011


People also ask

Is Facebook graph API deprecated?

API Version Deprecations: As part of Facebook's Graph API and Marketing API, please note the upcoming deprecations: August 3, 2021: Graph API v3. 3 will be deprecated and removed from the platform. August 25, 2021 Marketing API v9.

Is Facebook graph API restful?

Because the Facebook Graph API is a restful JSON API, you can run queries directly in any standard browser; you'd simply be making HTTP calls.

How do I update my Facebook graph API?

In the App Dashboard Settings > Advanced, scroll to the Upgrade API Version section.


2 Answers

Also note there is a new User permission, read_insights, which needs to be enabled, otherwise reading any /insights edge will fail silently with empty response. Permission dialogue with read_insights highlighted

like image 137
veproza Avatar answered Oct 11 '22 20:10

veproza


I had a similar issue. Several solutions on stackoverflow mostly attributed the issue to the lack of required permissions. Check the permissions you need by using the Graph API explorer or documentation (The tables have a column called permissions for each field). Some suggestions have been to use the scope to specifically mention which permissions you need in the login button or while making the call to the api. Eg:

FB.login(function (response) {         
if (response.authResponse) {        
    console.log('Welcome!  Fetching your information.... ');        
} else {       
console.log('User cancelled login or did not fully authorize.');        
}        
}, { scope: 'email,publish_stream,user_birthday,user_location' });  

I had a different issue where I had double-checked all the permissions set for my app dashboard that were correct, but while logging in, I had specified a scope with a set of permissions which seemed to override the app settings. :( I found this strange, but I rectified it by including the other permissions in the scope too and my problem was resolved.

An effective way to see if the right permissions are being set through the code is to use the following code:

 FB.api({ method: 'fql.query', query: 'SELECT     user_status,friends_status,user_photos,friends_photos,user_location,friends_location FROM     permissions WHERE uid=me()' }, function(resp) {        
for(var key in resp[0]) {        
    if(resp[0][key] === "1")        
        console.log(key+' is granted');        
    else        
        console.log(key+' is not granted');        
}        
});   

P.S: On one post I also found a solution which mentioned that the person was able to get the data after deleting the app from his Facebook account and testing by adding it again. Also make sure that if you changed the permissions in the app dashboard, you log out of your application and login again before testing.

I wasted over 3 hours trying to fix this issue and facebook documentation did not help me a bit, so hope this helps someone!

like image 41
sahithya Avatar answered Oct 11 '22 19:10

sahithya