我将在此消息中写下我的问题并通过exception
(#number)放置链接,我尝试创建将从库中创建的 Web 应用程序facebook4j
,我想获取有关用户帐户 facebook 的信息并在 facebook 上发布信息,在我的代码中我可以获得有关的 json 信息用户或朋友,但我从令牌中遇到问题,当我长时间工作时,我得到异常 #1。
我setOAuthAccessToken()
在graph api explorer
副本中生成了这个参数并将其粘贴到setOAuthAccessToken()
. 如何正确设置和获取令牌?
如何通过在我的 Web 应用程序中创建身份验证facebook4j
?
例外 #1
FacebookException{
statusCode=400,
errorType='OAuthException',
errorMessage='Errorvalidatingaccesstoken: SessionhasexpiredonFriday,
25-Sep-1511: 00: 00PDT.ThecurrenttimeisFriday,
25-Sep-1513: 55: 17PDT.',
errorCode=190,
errorSubcode=463,
version=2.3.0
}
这是我的代码:
private final String TOKEN_VALUE = "CAACEdEose0cBAN5JHf6qs85DCcqKndE3N9XxjnMye3m7G7Re4VpSCqn4IzWXXoYeQe3QlUOH0NGucIWJbqfZBpFoHTUZA60YcZCZBwd4kCWD4g1qwZCyxy1ihpoiVuxZCV1u9ydjnhZCkNOoSqiqPpkzDWPfAc8ZBEDFtCvW78gZCbkZChrzfsMxpA3LZC08pZA5HrqaOe1BnrU1PiZAHJz4ZAEm3M";
private FacebookFactory facebookFactory;
private Facebook facebook;
private ConfigurationBuilder configurationBuilder;
private Configuration configuration;
public ConfigurationBuilder getConfigurationBuilder(){
configurationBuilder = new ConfigurationBuilder();
configurationBuilder.setDebugEnabled(true);
configurationBuilder.setOAuthAppId("746931638784611");
configurationBuilder.setOAuthAppSecret("07e2df67b4fe40e3f2051d79f40387c2");
configurationBuilder.setOAuthAccessToken(token);
configurationBuilder.setUseSSL(true);
configurationBuilder.setJSONStoreEnabled(true);
return configurationBuilder;
}
public Configuration getConfiguration(){
return getConfigurationBuilder().build();
}
public FacebookFactory getFacebookFactory(){
return new FacebookFactory(getConfiguration());
}
@Override
public String getFriends() {
facebook = getFacebookFactory().getInstance();
try {
ResponseList<Friend> friends = facebook.getFriends();
return friends.toString();
}catch (FacebookException e) {
e.printStackTrace();
}
return null;
}