I have test my app before, and It worked I have managed to post to my page wall.
But now after I have changed the code and removed the permissions, and logged in again it didn't work and trowed this exception:

Exception: 200: The user hasn't authorized the application to perform this action

Code:

if(isset($_POST['submit'])){

try {
//$facebook = new Facebook(###, ###);


$facebook->api_client->session_key = '###';//I  got this by a tutorial once but I can't seem to get a new one, is there any way of getting one automatically?
$response = $facebook->api(array(
  'method' => 'stream.publish',
  'message' => 'Test from dreafmhosters.com',
  'target_id' => ##mypageid###;
));
} catch(Exception $e) {

echo $e . "<br />";
}
}
?>

Any solutions?

Dani AI

Generated

Short diagnosis: the failure is caused by an insufficient OAuth token or missing publish/manage permissions rather than a bug in the publish call itself. removed the app permissions and then forced a session_key into the SDK, which bypasses the normal OAuth handshake so the token no longer carries the scopes required to post (and it may be expired or the wrong kind of token for posting to a Page).

Practical checklist (most common fixes):

  • Stop hard‑coding or injecting a session_key; let the SDK manage the session and call getUser() / getAccessToken() so the current token is used.
  • Re‑run the OAuth flow requesting the publish scope (names have changed across API versions — historically publish_stream / later publish_actions) and request manage_pages when posting as a Page so a page access token can be returned.
  • When posting to a Page, obtain the page access token (via the accounts endpoint) and POST to the page feed endpoint rather than using the user token.
  • Log the full API error payload and token in use (avoid publishing secrets) to confirm which permission is missing or whether the token is expired/insufficient.

Example workflow (conceptual):

use SDK to get current user token
call /me/accounts with the user token to find PAGE_ID and its access_token
POST to /PAGE_ID/feed with the page access_token and message

Notes and caveats: ’s linked threads point toward the same permission/reauthorization guidance; the difference here is the manual session_key assignment, which prevents the app from obtaining the correct scopes. Also be aware that permission names, review requirements, and token lifetimes have changed over time — for any modern integration the current Facebook developer documentation and the SDK’s getAccessToken() / page token flow should be followed.

Recommended Answers

All 2 Replies

check the following links they same discussion link 1..... .....and ..... also can check the google search page

check the following links they same discussion link 1..... .....and ..... also can check the google search page

This did not help me...
Thanks anyways.
Please answer my question specifically.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.