问题
The goal of my app is purely to take news items, created on my website, and have them posted on the wall of my facebook page automatically. (not a user, but a business page). I have succeeded in getting the app to post to my user wall, but there several issues with that. For one, I need it to post on my BUSINESS page, and the access_token expires. I don't want it to expire, it needs to stay active so that any post to my website will continue to post to facebook.
Does anybody know of any straight forward way to doing this? The on that got me this far was this: http://nocturnsoft.com/devblog/?p=906. In the end, the two things I need to know is how to post to a business page using graph API, and I need to know how to extend the life of my access_token.
Thanks
回答1:
You need several things to achieve this:
- Active
access_token
for user who is admin of that page. manage_pages
andpublish_stream
permissions granted by that user.- Page
access_token
(which you can get fromaccounts
connection ofuser
object)GET http://graph.facebook.com/me/accounts
(will return array of details for every pages user own, withaccess_token
included for every page) - Create post by issuing
POST
requests tohttp://graph.facebook.com/PAGE_ID/feed
using pageaccess_token
.
As you said access_token
is something that can expire, you can't disable this (and it's not something bad, actually you can for a limited time because offline_access
permission exists, but it's deprecated) but you can extend the expire period for up to 60 days as described in Deprecation of Offline Access Permission developers blog post.
来源:https://stackoverflow.com/questions/9066941/problems-getting-app-to-post-to-a-page