Facebook Graph API Returning Empty Data Set

前端 未结 5 1033
不思量自难忘°
不思量自难忘° 2021-02-18 22:34

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

相关标签:
5条回答
  • 2021-02-18 23:22

    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).

    Screenshot of the graph explorer access token generator

    0 讨论(0)
  • 2021-02-18 23:24

    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.

    0 讨论(0)
  • 2021-02-18 23:35

    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!

    0 讨论(0)
  • 2021-02-18 23:35

    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.

    0 讨论(0)
  • 2021-02-18 23:37

    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.

    0 讨论(0)
提交回复
热议问题