用户尚未授权应用程序执行此操作

发布于 2024-12-24 01:52:59 字数 1158 浏览 2 评论 0 原文

我正在开发一个简单的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"
   }
}

如何授权我的应用程序发布到我的有趣的页面? 预先感谢

以下推荐

I am developing a simple java program to post automatically (articles) to my facebook fun page. I have created an app and have got an access_token using url : https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=APP_ID&client_secret=CLIENR_SECRET. I use this java code to post to fun page wall :

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();

I got this error:

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

How can I give my app authorization to post to my fun page ?
thanks in advance

following recommendation of

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

帝王念 2024-12-31 01:52:59

哇,我每天至少看到同样的问题被问一次。

您需要请求 manage_pagespublish_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 and publish_stream. Once the admin of the page authenticates, query me/accounts and grab the page's access token from that list. Using that page's access token, then you can post to me/feed.

痞味浪人 2024-12-31 01:52:59

简单,你只需要请求权限..就是这样..

String[] permissions = { "offline_access", "publish_stream", "user_photos", "publish_checkins","photo_upload" };
mFacebook.authorize(MainActivity.this, permissions,
            new LoginDialogListener());

simple, u just need to ask permissions..that's it..

String[] permissions = { "offline_access", "publish_stream", "user_photos", "publish_checkins","photo_upload" };
mFacebook.authorize(MainActivity.this, permissions,
            new LoginDialogListener());
花期渐远 2024-12-31 01:52:59

您正在使用应用程序 access_token,而您应该为用户或页面使用 access_token

更新:
要以管理员身份发布,您需要用户的 access_token。
要作为主页发布,您需要页面 access_token

You're using application access_token while you should use access_token for user or page.

  • User's access_token is present within signed_request (in cookie, or passed to application canvas).
  • Page access_token available in accounts connection of user once user granted manage_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

浮光之海 2024-12-31 01:52:59

Facebook 已将 publish_stream 权限更改为 publish_actions。因此,您需要同时应用 publish_actionsmanage_pages 权限。

Facebook has changed the publish_stream permission to publish_actions. So you need to apply both publish_actions and manage_pages permissions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文