简体   繁体   中英

Posting links to facebook page without user authentication

Basically I have a web app that will be posting links to a facebook page(not profile) wall.

As far as I know I need a permanent token to do this. Twitter gives me one straight off the account, so I was hoping facebook would have something similar. However the token I get with the manage_pages permission has an expiry.

From the authentication docs this is what I've been doing:

request token to manage pages:

https://www.facebook.com/dialog/oauth?client_id=123456789123&redirect_uri=http://myapp.com/fb&scope=manage_pages&response_type=token

get token back the url which I intend paste it into my apps config:

http://myapp.com/fb#access_token=123123123123123%7C2.18VYbalblablablaswhg__.3600.1304294400.1-615173155%7CTzb_U9ma0LIPJXNzqsZ_xUJpfn8&expires_in=4205

When I actually try to post to the page with this, I get an expired error.

$post_params = array(
'access_token' => self::$page_token,
'message' => $string
);
$response = $fb_app->api('/'.self::$page_id.'/feed','POST', $post_params);

You need the offline_access permission to get a permanent token. If you intend to post as the page itself, you need to get the token from /USER_ID/accounts for that page, else you will post from your profile. If you don't intend to post as the page, you actually don't need the manage_pages permission, publish_stream for the user is enough. Good luck.

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