开发者

Post to Facebook application page as APPLICATION user

开发者 https://www.devze.com 2023-02-01 07:30 出处:网络
I\'d like to write a status message to my application page with the application name. I\'m using $app_id = \'ID OF MY APPLICATON\'

I'd like to write a status message to my application page with the application name.

I'm using

$app_id = 'ID OF MY APPLICATON'
$facebook->api($app_id.'/feed', 'POST', array('message' => 'test'));

after the post is written my name is shown but I want instead开发者_开发问答 of my name the application name to be shown, is this possible to do?


App pages work the same as fan pages, so you'd just do the same as if you wanted it posted by a fan page

Info here - http://www.masteringapi.com/tutorials/how-to-post-on-facebook-page-as-page-not-as-admin-user-using-php-sdk/31/

The key is to use an access_token from the page, not the access_token of your user account

$result = $facebook->api("/me/accounts");
foreach($result["data"] as $page) {
    if($page["id"] == $page_id) {
        $page_access_token = $page["access_token"];
        break;
    }
}
$args = array(
    'access_token'  => $page_access_token,
    'message'       => "I'm a Page!"
);
$post_id = $facebook->api("/$page_id/feed","post",$args);
0

精彩评论

暂无评论...
验证码 换一张
取 消