I am trying to post Facebook Page status as page(not user) through my script. This returns me an error 100.
Here I am generating temporary user_access_token from Graph Explorer with permission : manage_pages, publish_pages
<?php
$url='https://graph.facebook.com/v2.3/{$user_id}/accounts?access_token=USER_ACCESS_TOKEN';
$ch=curl_init();
CURL_SETOPT($ch,CURLOPT_URL,$url);
CURL_SETOPT($ch,CURLOPT_RETURNTRANSFER, 1);
$json=json_decode(curl_exec($ch));
$page_access_token=$json->data['0']->access_token;
curl_close($ch);
$page_id='xxx';
$message='helloworld';
$url="https://graph.facebook.com/v2.3/{$page_id}?access_token=$page_access_token";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $message);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
$result = json_decode(curl_exec($curl));
var_dump($result);
?>
If everything goes well, a string "helloworld" should get posted on Facebook page. But here it is returning with an error :
object(stdClass)#5 (1) {
["error"]=>
object(stdClass)#6 (3) {
["message"]=>
string(61) "(#100) Parameters do not match any fields that can be updated"
["type"]=>
string(14) "OAuthException"
["code"]=>
int(100)
}
}
What is mistake here ? Thank you.
You're trying to post to /<PAGE_ID>
The correct endpoint for creating a post on a Page is /<PAGE_ID>/feed, documented here: https://developers.facebook.com/docs/graph-api/reference/v2.3/page/feed
A valid format for a basic call to create a post would be https://graph.facebook.com/v2.3/<PAGE_ID>/feed?message=helloworld&access_token=<ACCESS_TOKEN>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With