为什么 Spring social facebook -2.0.3 使用已弃用的图表 api 2.5 版已弃用

why Spring social facebook -2.0.3 using deprecated graph api version 2.5 which is deprecated

我们在生产环境中使用的是spring-social-facebook-2.0.3最新的jar。

2018 年 4 月图 api v2.5 将关闭。但是 spring-social-facebook-2.0.3 最新的 jar 仍在内部使用这个已弃用的图 API。

任何人都有任何知识,
Spring 团队是否会在下个月(即 2018 年 4 月)之前发布 spring-social-facebook 的新版本?

针对那些想要更改已使用的 API 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;
  }
}

Spring社交配置

@Configuration
@EnableSocial
public class SocialConfiguration implements SocialConfigurer {

  @Override
  public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {
    cfConfig.addConnectionFactory(new FacebookCustomApiVersionConnectionFactory("2.7", "appId","appSecret");

  }
...
}

我们可以通过以下方式简单地更改api版本

FacebookTemplate facebookTemplate=new FacebookTemplate(accessToken);
facebookTemplate.setApiVersion("3.2");
System.out.println("graph url"+facebookTemplate.getBaseGraphApiUrl());

该项目已过时。他们在 2018 年宣布停产,2019 年生效: https://spring.io/blog/2018/07/03/spring-social-end-of-life-announcement

他们建议只使用 Spring 安全性。