I have created application by checking all the checkbox of the permission.
I want to auto post to selected page. I have used the following code. When I am login to facebook then it will allow me to post to that selected page.
<?php
$fb = new Facebook\Facebook([
'app_id' => '{APP-ID}',
'app_secret' => '{APP-SECRET}',
]);
$linkData = [
'link' => 'http://www.example.com',
'message' => 'Auto',
];
try {
$response = $fb->post('/me/feed', $linkData, '{access-token}');
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$graphNode = $response->getGraphNode();
echo "<pre>"; print_r($graphNode);
die();
?>
I have got {access-token} by copying the token from the text-box nearby "Get Token" button.I want to get this {access-token} when I am not logged in.Please help. I am trying from the last two days.
I have got following errors:
- An access token is required to request this resource. An active
- access token must be used to query information about the current user.
Aucun commentaire:
Enregistrer un commentaire