Hi Guys I want to post on my facebook page by using Facebook PHP SDK v5. Here are my codes but after running, I get the following errors
*Fatal error: Uncaught exception 'Facebook\Exceptions\FacebookAuthorizationException' with message '(#200) Insufficient permission to post to target on behalf of the viewer' in ................
My codes
<?php
session_start();
require_once("Facebook/autoload.php");
use Facebook\Facebook;
use Facebook\FacebookRequest;
use Facebook\GraphNodes\GraphNode;
use Facebook\Helpers\FacebookRedirectLoginHelper;
use Facebook\Exceptions\FacebookSDKException;
use Facebook\Exceptions\FacebookResponseException;
$api_id="8888090.......";
$api_secret="6786bdcd97b18e94b9bbff4b2ecc723c";
$url="http://localhost/feedreader/feedpost.php";
$fb = new Facebook([
"app_id" => $api_id,
"app_secret" => $api_secret,
"default_graph_version" => "v2.2",
]);
$linkData = [
'link' => 'http://www.daniweb.com',
'message' => 'I Like DaniWeb IT Discussion Forum',
];
$helper=$fb->getRedirectLoginHelper();
try{
$token=$helper->getAccessToken();
if(isset($token))
{
$response = $fb->post('/357971644373038/feed', $linkData,$token);
$graphNode = $response->getGraphNode();
echo 'Posted with id: ' . $graphNode['id'];
}
else{
$permision=array("scope"=>"email,publish_actions,manage_pages");
echo "<a href='".$helper->getLoginUrl($url,$permision)."'>Click to post</a>";
}
}
catch (Facebook\Exceptions\FacebookSDKException $e)
{
echo $e->getMessage();
}
?>
Can any one Help me on this? I need your help guys....