I have a php script that attempts to POST a post to a Facebook page via CURL, but fails with the error.
(#200) If posting to a group, requires app being installed in the group, and either publish_to_groups permission with user token, or both pages_read_engagement and pages_manage_posts permission with page token; If posting to a page, requires both pages_read_engagement and pages_manage_posts as an admin with sufficient administrative permission
The exact same POST works from Facebooks API Graph Explorer. The same page access token is used in both cases. I have checked the token in Facebook's token debugger and the permissions mentioned in the error are both present.
The code I'm using is:
$post_content = "message=".$message."&access_token=".$ae_page_access_token;
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/v13.0/{page-ID}/feed');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_content);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
Interestingly, I can post photos with captions to the page with the same access token from my php script without an error. The error only happens when using https://graph.facebook.com/v13.0/{page-ID}/feed
-- the permissions just don't seem to work in this case. No idea why.
Can anyone suggest how to troubleshoot further or a possible cause? Any advice gratefully received
CodePudding user response:
Well this is embarrassing. Misspelled parameter in a function call was the culprit. Works now.
CodePudding user response:
Try this
$post_content = "message=".$message;
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/v13.0/{page-ID}/feed?access_token=' . $ae_page_access_token);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_content);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
token place is in url like a get parameter https://developers.facebook.com/docs/facebook-login/guides/access-tokens#pagetokens