简体   繁体   中英

Facebook timeline wallpost doesn't work as aspected

Im using the Facebook SDK Api [PHP] to post automaticly on a timeline wall.

I created a App and requested the access_token with the following permissions: manage_pages,publish_stream,offline_access.

Im using now the access_token to post the message on a page (/PAGEID/feed) where im moderator.

The following is going OKAY and get the post working under the name of the Facebook page:

$attachment = array(
    'access_token'      => $accessToken,
    'message'           => $description,
);

$res = $facebook->api('/PAGEID/feed', 'POST', $attachment);

When Im adding some link + name AND/OR picture it will post not as wall post but as "recent message of others" with as name my own user:

$attachment = array(
    'access_token'      => $accessToken,
    'message'           => $description,
    'link'              => 'http://www.google.nl',
    'name'              => $description,
    'picture'           => $image,
);

How can I post full messages with link and picture on the wall self?

If I understand you correctly, you are trying to post as the Page but it's showing up as a post by you. Is that correct?

If so, I think you need to post using the Page's access token, rather than your own access token. Look at the section called "Page Access Tokens" on https://developers.facebook.com/docs/reference/api/page/ . Once you get the page's access token using the technique described there, you can set it to be the token that PHP SDK uses by doing $facebook->setAccessToken(.... access token value ...). Then you can do the post and it should show up as having been created by the page.

This problem troubled me for so long. Everything seemed setup correctly but as soon as I added a link, it would post as Admin instead of Page. The answer above by triangle_man solved my problem. When using the PHP sdk, the specific line of code I needed was:

$page_token = $facebook->api("/$page_id?fields=access_token");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM