2

I am trying to use PHP SDK V4 to retrieve 'Facebook Page Ratings' in my website's page. For that I created an fb app, and got a page access token from Graph API Explorer.

As described in this link. My code was working properly when I access ONLY page details

$request = new FacebookRequest(
  $session,
  'GET',
  '/{page-id}'
);

But when I try to retrieve ratings of that Facebook page as described here-

$request = new FacebookRequest(
  $session,
  'GET',
  '/{page-id}/ratings'
);

I get following Error-

Fatal error: Uncaught exception 'Facebook\FacebookPermissionException' with message '(#210) Subject must be a page.'.......

Why is that? Please Help!

Sahil Mittal
  • 20,697
  • 12
  • 65
  • 90
Prashanth Reddy
  • 197
  • 2
  • 12

1 Answers1

2

You're getting this error coz you're not using the page access token with the API call.

Getting the page access token–

Instead of using the page access token from the Graph API Explorer, get one from the API call. Remember that the user must authorize the app with manage_pages permission. You'l l get the page access token in the response of following call (demo)-

$request = new FacebookRequest(
  $session,
  'GET',
  '/{page-id}?fields=access_token'
);

PS, if required, you can also get a page access token of a page which you authored that never expires. See this answer.

Using page access token with a call–

To get the ratings you have to use the page access token with the API /{page-id}/ratings, just like this-

$request = new FacebookRequest(
  $session,
  'GET',
  '/{page-id}/ratings?access_token='.$page_access_token  //use the page access token obtained from above step here
);

Note:

From v2.0 onwards, the permissions other than public_profile, email and the user_friends need to the submitted for review before you can make your app live; else you wont be able to use them. Only the testers/admin/developers of the app will be able to test with those permissions until the permissions are reviewed.

So, you just have to submit login review before you make your app live. Here are the details for login review

Community
  • 1
  • 1
Sahil Mittal
  • 20,697
  • 12
  • 65
  • 90
  • Thanks for the reply. When I try to get page access token, in the output i'm getting only 'id' of the page(using print_r( $graphObject, 1 );) – Prashanth Reddy Jun 27 '14 at 07:12
  • That's why I've written- `Remember that the user must authorize the app with manage_pages permission` – Sahil Mittal Jun 27 '14 at 07:13
  • While creating page access token i checked all check boxes including 'manage_pages'. Any way i'll check that again. – Prashanth Reddy Jun 27 '14 at 07:16
  • When I try to create an access token with permission 'manage_pages', it is giving this notice: The following permissions have not been approved for use: manage_pages. If you make your app public, they will not be shown to people using your app. Submit them for review or learn more. – Prashanth Reddy Jun 30 '14 at 10:38
  • This warning is quite straight-forward right? I've explained this in the edit, pls check. – Sahil Mittal Jun 30 '14 at 10:42
  • I created this app just to display fan page's reviews in my website. This is not a public app. As I am the admin, is there any way to skip this 'submit' process. – Prashanth Reddy Jun 30 '14 at 12:46
  • I'm still not sure what exactly your app does; but if only YOU are going to login and use your data to the website, you can let your app in the development mode. – Sahil Mittal Jun 30 '14 at 13:10