如何以编程方式发布到喜欢的网页的Facebook Feed?

时间:2012-05-02 18:14:03

标签: facebook facebook-graph-api

我正试图让这个工作:https://developers.facebook.com/blog/post/465/

第1步:我正在获取访问令牌:

https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=myAppIdclient_secret=myAppSecret

第2步:我是通过curl发布的

curl -F 'access_token=myAccessToken'  -F 'message=Hello World!'  -F 'id=http://example.com'  https://graph.facebook.com/feed

myUrl在哪里说http://example.com

我收到此错误,无法解析为有效的用户ID:

{"error":{"message":"(#100) http:\/\/example does not resolve to a valid user ID","type":"OAuthException","code":100}}

第3步:如果我首先将我的网址发布到linter,并获取其ID:

https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fexample.com

https://graph.facebook.com/10150096126766188

curl -F 'access_token=myAccessToken'  -F 'message=Hello World!'  -F 'id=10150096126766188'  https://graph.facebook.com/feed

然后我得到'用户未授权应用程序执行此操作'错误:

{"error":{"message":"(#200) The user hasn't authorized the application to perform this action","type":"OAuthException","code":200}}

2 个答案:

答案 0 :(得分:0)

来自Facebook Graph API docs

Most write operations require extended permissions[1] for the active user.
See the authentication guide[2] for details on how you can request extended
permissions from the user during the authentication step.

1 https://developers.facebook.com/docs/authentication/permissions

2 https://developers.facebook.com/docs/authentication/

答案 1 :(得分:0)

通过博客文章,这是通过应用程序完成的,为此,应用程序需要扩展权限'publish_actions'和'publish_stream'才能发布帖子/评论/赞成/链接