gpt4 book ai didi

java - 线程 "main"com.restfb.exception.FacebookOAuthException : Received Facebook error response of type OAuthException 中出现异常

转载 作者:行者123 更新时间:2023-12-01 04:28:43 25 4
gpt4 key购买 nike

我正在使用restFB API运行一个简单的代码,在我创建 token 访问后,程序正在运行,从我的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());

}

以前有人遇到过这样的异常吗?

最佳答案

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

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

关于java - 线程 "main"com.restfb.exception.FacebookOAuthException : Received Facebook error response of type OAuthException 中出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18207912/

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