Facebook:收到 OAuthException 类型的 Facebook 错误响应:无效的 OAuth 访问令牌。 (代码 190,子代码为空)

Facebook: Received Facebook error response of type OAuthException: Invalid OAuth access token. (code 190, subcode null)

情况: 我能够通过网络应用程序获取访问令牌,以及我的个人资料名称和个人资料 ID。我将此代码添加到 post 我墙上的一条消息:

@SuppressWarnings("deprecation")
FacebookClient fbClient = new DefaultFacebookClient(accessToken, MY_APP_SECRET);
FacebookType publishMessageResponse =  fbClient.publish("me/feed", FacebookType.class,
        Parameter.with("message", "RestFB test 123"));

com.restfb.exception.FacebookOAuthException:收到 OAuthException 类型的 Facebook 错误响应:无效的 OAuth 访问令牌。 (代码 190,子代码为空)

问题: 我收到错误消息:

Received Facebook error response of type OAuthException: Invalid OAuth access token. (code 190, subcode null)

我试过的:我正在使用 restFb1.13(最新版本)。我也尝试使用较旧的 restFb1.7,但错误仍然存​​在。我在文档中找不到上述错误代码。不幸的是,在 Whosebug 和其他网站上搜索并没有列出这个错误。

任何建议都会很有帮助。

解决了。问题是从 facebook 收到的 Accesstoken 的格式是:AccessToken= some long alphanumeric string&expires=some string。我们必须去掉 "Accesstoken=" 和 "expires=" 之间的部分。

我做到了

String accessToken;
accessToken = accessToken.substring(13,accessToken.lastIndexOf("&"));