facebookfacebook-graph-apifacebook-javascript-sdk

Get Reviewer info from Facebook Graph API Rating call


I'm facing a weird problem with the Facebook Graph API.

My goal is to get specific Page Ratings in order to display them on a website.

I'm using the JavaScript SDK and followed everything the documentation said about page's access token.

Here is my Facebook Login button in order to get my App authorized by the current user account (in that case it's mine) with correct Admin Role for the Page :

<fb:login-button id="fb-login-btn" scope="manage_pages,pages_show_list" onlogin="checkLoginState();">

Then I'm getting all the user's Pages with the help of the /me/accounts API call:

FB.api('/me/accounts', function(response) {

  if(response && !response.errors) {
    const selectList = document.getElementById('fb-page-list');

    // Populate the list
    response.data.forEach(page => {
      var option = document.createElement("option");
      option.value = JSON.stringify({id: page.id, access_token: page.access_token});
      option.text = page.name;
      selectList.appendChild(option);
    });
  }
});

So when the client will select a Page name it will get the correct Page's access token in order to make Page specific API call after.

Then the last step is the Page's ratings call:

FB.api(
  '/'+ page.id + '/ratings?access_token='+ page.access_token +'&limit=10?fields=reviewer{id,name,picture},rating}',
  function(response) {
    console.log(response);
  }
);

So, when I execute that query in the Graph API Explorer (which is provided by the Facebook Developer interface) it works perfectly. I get my ratings as:

Graph API Explorer

When I try in a browser, I also get my ratings but only some of the default fields (i.e created_time, review_text, rating).

The reviewer field is a default field. So, I did tried to query without any field parameters and it acts the same.

Initially, I thought that it was about permissions but in the documentation it says that only 'manage_pages' is needed.

How can I overcome this issue?


Solution

  • Same problem here, but with PHP SDK. I asked to the Facebook support center for developers, and they replied quickly. The reason is associated to recent changes and here what they suggested to me, according to the documentation:

    "For dev mode apps, 'App users can only access the data of users who have a role on the app.' https://developers.facebook.com/docs/apps/security Please submit your app for app review and publish your app to access the user info."

    I didn't try yet, hope this can fix our problem