gpt4 book ai didi

java - 没有执行操作的授权 - 但该应用程序已获得授权

转载 作者:太空宇宙 更新时间:2023-11-04 12:47:38 25 4
gpt4 key购买 nike

我想使用restfb 发布到我的页面之一。我想以页面本身的形式发布,而不是以用户的形式发布到页面墙上。

这是我正在使用的代码:

public class App {
//user token for accessing the page as admin
private static final String INITIAL_ACCESS_TOKEN = "#";

public static void main(String[] args) throws Exception {
restfb();
}

public static void restfb() throws Exception {
DefaultFacebookClient fbClient;
Connection myAccounts;
fbClient = new DefaultFacebookClient(INITIAL_ACCESS_TOKEN, Version.VERSION_2_5);
myAccounts = fbClient.fetchConnection("me/accounts", Account.class);
String pageToken = null;
//retrieve the page token
for(Object a : myAccounts.getData()) {
Account account = (Account)a;
if("MyPage".equals(account.getName())) {
pageToken = account.getAccessToken();
break;
}
}
System.out.println(pageToken); //not null here

//post to the page
fbClient = new DefaultFacebookClient(pageToken, Version.VERSION_2_5);
//"me" should refer to the page itself..?
fbClient.publish("me/feed", FacebookType.class, Parameter.with("message", "Aloha! ;)"));
}
}

我收到错误

Received Facebook error response of type OAuthException: (#200) The user hasn't authorized the application to perform this action (code 200, subcode null)

我已经访问过此网址:

https://www.facebook.com/dialog/oauth?client_id=###&redirect_uri=###&scope=manage_pages,publish_actions,user_actions:pagealias&response_type=code

它要求我授予我的应用发布和管理我的页面的权限,我授予了它们。

该应用程序不是公开的,因为它是我想用于开发的测试应用程序(因此我没有要求审核)。

我错过了什么?该应用程序还需要哪些其他权限才能工作并正确发布?

最佳答案

您应该请求 publish_pages 权限才能以页面形式发布。 https://developers.facebook.com/docs/facebook-login/permissions#reference-publish_pages

关于java - 没有执行操作的授权 - 但该应用程序已获得授权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36162302/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com