PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, March 6, 2022

[FIXED] Not able to get Facebook Reviews through PHP SDK V4. Error: (#210) Subject must be a page

 March 06, 2022     facebook, facebook-graph-api, facebook-php-sdk, php     No comments   

Issue

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!


Solution

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



Answered By - Sahil Mittal
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing