API (Php SDK) üzerinden admin olarak Facebookpage göndermek nasıl?

0 Cevap php

I know how to make a post to a Facebook page via the API using PHP SDK, that is done like this:

$facebook->api('/xxxxxxxxxxx/feed', 'post', array('message'=> 'Hello world!', 'cb' => ''));

Where xxxxxxxxxxx is page id ;)

But doing that, I post to that page as me, Jamie, and not as the Page itself (admin).
So how do I post as Admin/Page instead of myself?

Zaman ayırdığınız için teşekkürler sana!

ANSWER (for lazy people):

Eğer emin kullanıcı için sayfalarını yönetmek erişimi, eski olduğundan emin olmak için gereken her şeyden önce:

<fb:login-button autologoutlink="true" perms="manage_pages"></fb:login-button>

Now you also gets a special token for every page user have access to once you get them.
PHP SDK Example:

//Get pages user id admin for
$fb_accounts = $facebook->api('/me/accounts');
//$fb_accounts is now an array 
//holding all data on the pages user is admin for, 
//we are interested in access_token 

//We save the token for one of the pages into a variable 
$access_token = $fb_accounts['data'][0]['access_token'];

//We can now update a Page as Admin
$facebook->api('/PAGE_ID/feed', 'post', array('message'=> 'Hello!', 'access_token' => $access_token, 'cb' => ''));

0 Cevap