通过所有的文章和指南,我可以't seem to figure out how to authenticate with Facebook so that I could post from our website to our Facebook page. Can you please give me some sort of 2751023 ? The main thing is that I can'弄清楚如何获得 acces_token
. 问题是:
-
我需要先创建某种
facebook application
吗? -
应用程序会以页面管理员的身份发布到页面的墙上,还是作为应用程序,换句话说 - 如何以页面管理员的身份进行操作?
2 回答
是的,你必须创建一个Facebook应用程序,以便让你的网站用户在Facebook上发布他们的东西 .
使用OAuth 2.0的身份验证过程非常简单:
来电
https://graph.facebook.com/oauth/authorizeclient_id=<your app's client_id>&redirect_uri=<your redirect URU>
. 如您所见,您必须传输您的client_id和一个URI,Facebook将在流程结束时重定向 . 您还可以传输数据参数,该参数将在整个过程中保持不变 . 用于跟踪用户 .call
https://graph.facebook.com/oauth/access_token?client_id=<your app's client_id>&redirect_uri=h<your redirect URU>&client_secret=<your app's client_secret>&code=<code>
代码参数由上一步调用重定向URI给出调用
https://graph.facebook.com/me?access_token=<access_token>
,使用前一个重定向返回的ad-hoc access_token,然后得到真正的 access_token .更多信息:
http://developers.facebook.com/docs/authentication/
您需要从opengraph explorer找出您的用户ID和访问令牌
以下Java代码(使用apache http client)在facebook墙上发布指定用户标识的消息 .