我们在生产环境中使用spring-social-facebook-2.0.3最新jar。
2018年4月,图表api v2.5即将关闭。但是spring-social-facebook-2.0.3最新jar仍在内部使用这个已弃用的图形API。
任何人都有任何知识,
春季团队将在下个月(即2018年4月)发布spring-social-facebook的新版本?
答案 0 :(得分:5)
想要在2.0.3版本和Facebook API升级工具中更改使用过的API版本的人的解决方案说它不会影响他们的应用程序:
public class FacebookCustomApiVersionConnectionFactory extends OAuth2ConnectionFactory<Facebook> {
public FacebookCustomApiVersionConnectionFactory(String apiVersion, String appId, String appSecret) {
super("facebook", new FacebookCustomApiVersionServiceProvider(apiVersion, appId, appSecret, null), new FacebookAdapter());
}
}
/**
* Facebook ServiceProvider implementation that allows to change Facebook API version.
*/
public class FacebookCustomApiVersionServiceProvider extends AbstractOAuth2ServiceProvider<Facebook> {
private final String appNamespace;
private final String apiVersion;
/**
* Creates a FacebookServiceProvider for the given API version, application ID, secret, and namespace.
*
* @param apiVersion Facebook API version
* @param appId The application's App ID as assigned by Facebook
* @param appSecret The application's App Secret as assigned by Facebook
* @param appNamespace The application's App Namespace as configured with Facebook. Enables use of Open Graph operations.
*/
public FacebookCustomApiVersionServiceProvider(String apiVersion, String appId, String appSecret, String appNamespace) {
super(getOAuth2Template(apiVersion, "https://graph.facebook.com/v" + apiVersion + "/", appId, appSecret));
this.apiVersion = apiVersion;
this.appNamespace = appNamespace;
}
private static OAuth2Template getOAuth2Template(String apiVersion, String graphApiUrl, String appId, String appSecret) {
OAuth2Template oAuth2Template = new OAuth2Template(appId, appSecret,
"https://www.facebook.com/v" + apiVersion + "/dialog/oauth",
graphApiUrl + "oauth/access_token");
oAuth2Template.setUseParametersForClientAuthentication(true);
return oAuth2Template;
}
public Facebook getApi(String accessToken) {
FacebookTemplate facebook = new FacebookTemplate(accessToken, appNamespace);
facebook.setApiVersion(apiVersion);
return facebook;
}
}
春季社交配置
@Configuration
@EnableSocial
public class SocialConfiguration implements SocialConfigurer {
@Override
public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {
cfConfig.addConnectionFactory(new FacebookCustomApiVersionConnectionFactory("2.7", "appId","appSecret");
}
...
}
答案 1 :(得分:0)
我们可以按照以下方式简单地更改api版本
FacebookTemplate facebookTemplate=new FacebookTemplate(accessToken);
facebookTemplate.setApiVersion("3.2");
System.out.println("graph url"+facebookTemplate.getBaseGraphApiUrl());
答案 2 :(得分:0)
该项目已过时。他们宣布2018年寿终正寝于2019年生效: https://spring.io/blog/2018/07/03/spring-social-end-of-life-announcement
他们建议改用Spring Security。