用户尚未授权应用程序执行此操作
我正在开发一个简单的java程序来自动发布(文章)到我的facebook fun页面。我创建了一个应用程序并使用 url 获得了 access_token : https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=APP_ID&client_secret=CLIENR_SECRET。我使用此 java 代码发布到有趣的页面墙:
String url = "https://graph.facebook.com/" + PAGE_ID + "/feed"
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("access_token", accessToken));
nvps.add(new BasicNameValuePair("message", item.getTitle()));
HttpClient client = new DefaultHttpClient(params);
HttpPost httpost = new HttpPost(url);
httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
HttpResponse response = client.execute(httpost);
HttpEntity entity = response.getEntity();
我收到此错误:
{
"error": {
"message": "(#200) The user hasn't authorized the application to perform this action",
"type": "OAuthException"
}
}
如何授权我的应用程序发布到我的有趣的页面? 预先感谢
以下推荐
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
哇,我每天至少看到同样的问题被问一次。
您需要请求
manage_pages
和publish_stream
。页面管理员通过身份验证后,查询me/accounts
并从该列表中获取页面的访问令牌。使用该页面的访问令牌,您就可以发布到me/feed
。Wow, I see this same question asked at least once a day.
You will want to ask for
manage_pages
andpublish_stream
. Once the admin of the page authenticates, queryme/accounts
and grab the page's access token from that list. Using that page's access token, then you can post tome/feed
.简单,你只需要请求权限..就是这样..
simple, u just need to ask permissions..that's it..
您正在使用应用程序
access_token
,而您应该为用户或页面使用access_token
。access_token
存在于signed_request
(在 cookie 中,或传递到应用程序画布)。access_token
可在 accounts 连接中使用>用户
一旦用户向您的应用授予manage_pages
权限。更新:
要以管理员身份发布,您需要用户的 access_token。
要作为主页发布,您需要页面
access_token
You're using application
access_token
while you should useaccess_token
for user or page.access_token
is present withinsigned_request
(in cookie, or passed to application canvas).access_token
available inaccounts
connection ofuser
once user grantedmanage_pages
permission to your app.Update:
To post as Administrator you'll need the user's access_token.
To post as Page you'll need page
access_token
Facebook 已将
publish_stream
权限更改为publish_actions
。因此,您需要同时应用publish_actions
和manage_pages
权限。Facebook has changed the
publish_stream
permission topublish_actions
. So you need to apply bothpublish_actions
andmanage_pages
permissions.