Home php facebook graph api returning ERROR (#210) This call requires a Page access token
Reply: 0

php facebook graph api returning ERROR (#210) This call requires a Page access token

Muhammad Asif Raza
1#
Muhammad Asif Raza Published in 2018-02-13 21:37:26Z

I am trying to get the ratings and reviews of my facebook page via Graph API. Here are the steps I followed

1) downloaded the SDK V2.1

2) Placed the following code in my php file

require_once __DIR__ . '\Facebook\autoload.php'; // change path as needed

$fb = new \Facebook\Facebook([
  'app_id' => 'my_app_id',
  'app_secret' => 'my_app_secret_key',
  'default_graph_version' => 'v2.10',
  //'default_access_token' => 'access_token', // optional
]);


try {
  // Get the \Facebook\GraphNodes\GraphUser object for the current user.
  // If you provided a 'default_access_token', the '{access-token}' is optional.
  $response = $fb->get('/me', 'access_token');
} catch(\Facebook\Exceptions\FacebookResponseException $e) {
  // When Graph returns an error
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(\Facebook\Exceptions\FacebookSDKException $e) {
  // When validation fails or other local issues
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}

$me = $response->getGraphUser();
echo 'Logged in as ' . $me->getName();

//echo '<pre>'; print_r($response);

When I run this code with app_id, app_secret and access_token it runs fine and gives me a message Logged in as Muhammad Asif Raza.

But as I need the ratings and reviews of the page so I changed

$response = $fb->get('/me', 'access_token');

to

$response = $fb->get('/page-id/ratings', 'access_token');

By doing so it gives me this strange error Graph returned an error: (#210) This call requires a Page access token. I have double checked the credentials + page-id of my page, don't know where I am doing wrong. Any help for me ?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.330581 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO