Facebook Graph API Returning Empty Data Set

妖精的绣舞 提交于 2019-12-03 23:03:26

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.

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!

I had a similar issue. I was also a 'Manager' for a page (from the page admin page on facebook: Edit page > Manage admin roles). Having that is not enough - one should also make sure the access token that is being used has a 'manage_pages' extended permission.

Also refer to the Facebook documentation (specifically section 2).

I was unaware that the ability to view my 'pages' from /me/account required that I have an additional 'page admin' access permission. Once the app owner granted me it within the app, I was able to see the data in the Graph Explorer.

I also had same problem while fetching my photos of an album. solved this by adding a permission named "user_status" in my access token.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!