使用RestFB api发布到Facebook页面墙

编程入门 行业动态 更新时间:2024-10-28 20:24:55
本文介绍了使用RestFB api发布到Facebook页面墙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正试图张贴在Facebook页面的墙上。我可以使用App Access令牌在用户墙上发布。

I am trying to post on the wall of a facebook page. I am able to post on the user wall using App Access token.

我通过扩展DefaultFacebookClient

I got the App Access Token through extending the DefaultFacebookClient

public class ConnectionService extends DefaultFacebookClient{ public ConnectionService(String appId, String appSecret) { AccessToken accessToken = this.obtainAppAccessToken(appId, appSecret); this.accessToken = accessToken.getAccessToken(); } }

有了这个,我可以发布到用户墙使用appID和appSecret。但是,当我试图发布用户没有授权应用程序执行此操作的页面错误获取错误

With this I am able to post to user wall using the appID and appSecret. But when I tried to post to Page Wall i get error of " The user hasn't authorized the application to perform this action"

任何人都可以建议? / p>

Anyone can advice?

推荐答案

应用访问令牌是最基本的,不允许您发布任何内容。为了向Facebook页面(作为页面)发布某些内容,您需要获取页面访问令牌。

The App Access Token is the most basic one, and will not allow you to post anything. In order to post something to a Facebook Page (as a Page), you need to get a Page Access Token.

该过程有点复杂,因为您实际需要要授权用户首先使用manage_pages权限,使用用户访问令牌,您可以调用API获取页面访问令牌(/ me / accounts)。

The process is a bit complicated, because you actually need to authorize the user with the "manage_pages" permission first, with the User Access Token you can call the API to get a Page Access Token (/me/accounts).

看到这些链接:

  • developers.facebook/docs/facebook-login/
  • developers.facebook/docs/facebook-login/access-tokens/
  • www.devils-heaven/facebook-access-tokens/
  • developers.facebook/docs/facebook-login/
  • developers.facebook/docs/facebook-login/access-tokens/
  • www.devils-heaven/facebook-access-tokens/

Btw,REST API已弃用: https:// dev elopers.facebook/blog/post/616/

Btw, the REST API is deprecated: developers.facebook/blog/post/616/

您还可以尝试客户端令牌(开发人员设置>高级),我从来没有工作与那个,但它可能是最简单的解决方案。无论如何,App Access Token是错误的。

You can also try the "Client Token" (Developer Settings > Advanced), i never worked with that one but it could be the easiest solution. In any case, an App Access Token is the wrong one.

更多推荐

使用RestFB api发布到Facebook页面墙

本文发布于:2023-10-11 14:01:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1481903.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:页面   RestFB   api   Facebook

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!