I am working on Auto Posting on facebook page or group by using graph api. But i get error of permissions but i allow permissions But i face this error. Any one who know about this error.
Code given below.
I share some images Which error showing me or how to allow permissions.
<?php
require_once ('vendor/autoload.php');
$fb = new FacebookFacebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
]);
$pageAccessToken = '{page-access-token}';
$MsgData = [
'message' => 'Hi, My name is Zaheer'
];
try {
$response = $fb->post('/me/feed/' , $MsgData , $pageAccessToken );
}
catch ( FacebookExceptionsFacebookResponseException $e ) {
echo 'Graph returned an error ' . $e->getMessage();
exit;
}
$GraphNode = $response->getGraphNode();
echo 'ID :' . $GraphNode['id'];
?>
[![enter image description here][2]][2]
2
Answers
Debug your Token: https://developers.facebook.com/tools/debug/accesstoken
You can see that it is a User Token, not a Page Token. Page Tokens can be generated by using a User Token with the following endpoints:
/me/accounts?fields=access_token
/page-id?fields=access_token
Make sure to use page token. You can easily get one from the the graphi api explorer on the right panel. I was having permissions error. My app type was business and to remove it, I just added all the permissions from the given list and after I added all permissions, facebook asked me to review permissions, I simply kept clicking on OK and everything worked, the error went 😀