質問

I want my application to post to a single, pre-defined user's wall something like "We just posted a new blog at [URL]" with no client-side interaction.

But every answer I can find on this topic seems to hinge on getting an access token through

https://graph.facebook.com/oauth/access_token

Which gives you some redirect url through which a user has to log in manually.

I've got near zero experience with Facebook. Is it possible to automatically get an access token for a predefined user? Am I doing it wrong? ;)

役に立ちましたか?

解決

You can't.

Facebook doesn't give you a way to automatically get an access token for a user. That user needs to log into Facebook and explicitly give your app permission. The best you can get is a long-lived access token that remains valid for up to 60 days.

Getting that token requires a two step process:

1) Logging into Facebook using either the JavaScript API or redirecting the user to a valid Facebook login URL. 2) Retrieving the short-lived access token you got in step 1 for a long-lived access token.

Once you've got that access token, should your post fail, you know you need to re-authenticate the user and get a new long-lived access token. Your user needs to be online and logged into Facebook for this to work, though it can happen without their interaction.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top