使用RestFB api发布到Facebook页面墙 [英] Post to Facebook Page wall using RestFB api

查看:223
本文介绍了使用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).

看到这些链接:

  • https://developers.facebook.com/docs/facebook-login/
  • https://developers.facebook.com/docs/facebook-login/access-tokens/
  • http://www.devils-heaven.com/facebook-access-tokens/

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

Btw, the REST API is deprecated: https://developers.facebook.com/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页面墙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆