I want to post on my Facebook page wall as a page using PHP. I have access_token from the links below.
https://graph.facebook.com/oauth/authorize?type=user_agent&client_id=123456789&redirect_uri=http%3A%2F%2Fmysite.net&scope=publish_stream,manage_pages,offline_access
https://graph.facebook.com/me/accounts?access_token=...
I am using this simple code:
$appid = "";
$secret = "";
$pageid = "";
$access_token = "";
require_once("facebook-php-sdk/src/facebook.php");
$facebook = new Facebook(array(
'appId' => $appid,
'secret' => $secret
));
try {
$args = array(
'access_token' => $access_token,
'message' => 'Test',
'link' => 'http://www.test.com',
'description' => 'Test'
);
$post_id = $facebook->api("/$pageid/feed","post",$args);
} catch (FacebookApiException $e) {
error_log($e);
}
And what is the error I get:
OAuthException: (
But posting / me / feed will not work. All the solutions I was looking for in googled no longer work, the official documentation did not help. I got it working when posting as a user (not a page) and using the javascript api (requires a “joint click action” by the user).
Does anyone know a solution for automatically posting to an fb page as a page? Spent a couple of disappointing days trying to figure it out. -_-
Thank,
and.
source
share