我将在此消息中写下我的问题,并按exception
(#number)放置链接,我尝试创建来自库facebook4j
的Web应用程序,我想获取有关用户帐户facebook的信息并发布关于Facebook的信息,在我的代码中我可以获得关于用户或朋友的json信息,但是我从令牌中遇到问题,当我长时间工作时我得到异常#1。
我在setOAuthAccessToken()
副本中生成了此参数graph api explorer
,并将其粘贴到setOAuthAccessToken()
。 如何正确设置和获取令牌?
如何通过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;
}