0

I have followed the steps from.

Facebook Access Token for Pages

And generated a page access token, then used the following code

<?php
include 'includes/facebook.php';
$app_id = "XXXXXXXXXXXX";
$app_secret = "XXXXXXXXXXXX";
$page_id = "XXXXXXXXXXXX";
$my_url = "http://XXXXXXXXXXXX.com";
$page_access_token = "XXXXXXXXXXXX";

//Create the facebook object
$facebook = new Facebook(array(
 'appId' => $app_id,
 'secret' => $app_secret,
 'cookie' => true
));

//Write to the Page wall
try {
    $attachment = array(
                'access_token' => $page_access_token,
                'message'=> "Hello World"
        );

   $result = $facebook->api('page_id/feed', 'post',  $attachment);

} catch (FacebookApiException $e) {
    error_log($e);
echo $e;
}

?>

It works for the first time but whenever the admin logged out, it's showing the error.

"OAuthException: Error validating access token: The session is invalid because the user logged out."

I tried a lot of suggestions but failed.

Community
  • 1
  • 1

1 Answers1

-1

Try and replace

'page_id/feed'

with

$page_id.'/feed' 

this should provide facebook api with correct destination page id

Augusto
  • 2,125
  • 18
  • 27