Facebook4j访问令牌错误2500

时间:2015-03-03 15:52:35

标签: java facebook facebook-java-api

我想通过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));

1 个答案:

答案 0 :(得分:0)

  1. 您可以转到以下链接:https://developers.facebook.com/tools/explorer/

  2. 您可以选择自己创建并想要访问的应用。

  3. .setOAuthAccessToken(“用户访问令牌”)

  4. accessToken = oAuthSupport.getOAuthAccessToken(); // NOT AppAccessToken !!!

  5. 然后它应该工作