我想使用facebook4j库从facebook获取数据,但是我收到此错误


  必须使用活动访问令牌来查询有关
  当前用户。代码-2500


代码:

ConfigurationBuilder confBuilder = new ConfigurationBuilder();
    confBuilder.setDebugEnabled(true);
    confBuilder.setOAuthAppId("MY ID APP");
    confBuilder.setOAuthAppSecret("MY APP SECRET");
    confBuilder.setUseSSL(true);
    confBuilder.setJSONStoreEnabled(true);
    Configuration configuration = confBuilder.build();

    FacebookFactory facebookFactory = new FacebookFactory(configuration );
    Facebook facebookClient = facebookFactory.getInstance();
    AccessToken accessToken = null;

     OAuthSupport oAuthSupport = new OAuthAuthorization(configuration );
     accessToken = oAuthSupport.getOAuthAppAccessToken();

    facebookClient.setOAuthAccessToken(accessToken);

    ResponseList<Post> feeds = facebookClient.getHome(new Reading().limit(1000));

最佳答案

您转到以下链接:https://developers.facebook.com/tools/explorer/
在这里,您选择要创建的应用程序,并希望从中访问该应用程序。
.setOAuthAccessToken(“用户访问令牌”)
accessToken = oAuthSupport.getOAuthAccessToken(); //不是AppAccessToken !!!


那应该工作

关于java - Facebook4j访问 token 错误2500,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28836069/

10-12 21:16