post a feed on my facebook application fan page

2020-07-30 03:20发布

问题:

I know how to post something on my wall $facebook->api('/me/feed/', 'post', $feed); but how to post feed on my facebook application page and this feed must be posted by the app

回答1:

Here you go:

// we need to get an application access_token first
$token_url = "https://graph.facebook.com/oauth/access_token?" .
   "client_id=" . $app_id .
   "&client_secret=" . $app_secret .
   "&grant_type=client_credentials";
$app_token = file_get_contents($token_url);

// seperate the string returned to use it in the post array
$arr = explode("=",$app_token);
$app_token = $arr[1];

$post_id = $facebook->api("/$app_id/feed", "POST", array("access_token"=>$app_token,"message"=>"hello app!"));