1

我正在使用restFB API运行一个简单的代码,在我创建令牌访问之后,程序正在运行,从我的Facebook帐户中检索数据,但过了一会儿我收到了这条异常消息

Exception in thread "main" com.restfb.exception.FacebookOAuthException: Received Facebook error response of type OAuthException: Error validating access token: Session has expired at unix time 1376380800. The current unix time is 1376392638.
    at com.restfb.DefaultFacebookClient$DefaultGraphFacebookExceptionMapper.exceptionForTypeAndMessage(DefaultFacebookClient.java:766)
    at com.restfb.DefaultFacebookClient.throwFacebookResponseStatusExceptionIfNecessary(DefaultFacebookClient.java:688)
    at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:630)
    at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:592)
    at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:556)
    at com.restfb.DefaultFacebookClient.fetchObject(DefaultFacebookClient.java:244)
    at Example.main(Example.java:19)

我运行的产生上述异常的代码如下:

public static void main(String[] args) {
    FacebookClient facebookClient = new DefaultFacebookClient("Token_Access_Code");

    User user = facebookClient.fetchObject("me", User.class);
    Page page = facebookClient.fetchObject("cocacola", Page.class);

    System.out.println("User name: " + user.getName());
    System.out.println("Page likes: " + page.getLikes());

}

有没有人经历过这样的异常?

4

1 回答 1

0

您需要重新生成访问令牌。我遇到了同样的错误,即使根据 FB 文档,访问令牌应该持续 60 天。检查此链接:

http://developers.facebook.com/docs/facebook-login/access-tokens/#extending

于 2013-10-24T07:14:29.613 回答