3

How can I find out, which version of spring-social-facebook uses which version of Facebook's Graph API?

Is there a chance to configure the API version in spring-social-facebook?

I'm asking this, as in the moment (31.10.2016) the newest version of spring-social-facebook is not compatible to the actual facebook API. An exception is thrown: "(#12) bio field is deprecated for versions v2.8 and higher".

In the moment I'm only developing - but I am unsure, how to avoid this kind of error in a release version. How can I make sure, that changes in facebook's API don't crush my application?

olivmir
  • 692
  • 10
  • 29

1 Answers1

3

In order to know which Facebook’s Graph API version is implemented by a spring-social-facebook release you could see the official announcements on spring site: i.e. 2.0.0.RELEASE implements v2.3 of Facebook’s Graph API, 2.0.3.RELEASE implements v2.5, and so on.

In v2.0.3.RELEASE of spring-social-facebook was introduced the method FacebookTemplate.setApiVersion(String apiVersion): you have the possibility to set the Facebook’s Graph API version in order to use the same one configured on your facebook app. In detail, when the getBaseGraphApiUrl() method is called the url is dinamically built with the api version provided by the setApiVersion method ("https://graph.facebook.com/v" + apiVersion + "/").

Unfortunately, although no one forbids you to provide a Facebook’s Graph API version greater than the target version implemented by a spring-social-facebook release, you have no guarantee that everything works properly (i.e. you cannot resolve the bio field problem setting the api version with value 2.8 by setApiVersion method) then this is not a solution.

To answer your last question, I suggest you to implement this workaround, wait the next spring announcement and use the next spring-social-facebook release when it will be fully compatible with the api version of your facebook app (v2.8 I suppose), so you'll be able to use all the api (i.e. facebook.userOperations().getUserProfile()) without errors. Moreover, your facebook app will still use v2.8 of Facebook’s Graph API (even if a new version of Facebook’s Graph API will be released) and then the spring-social-facebook release that you'll use (for example in a production env) will continue to be fully compatible with it.

Community
  • 1
  • 1
user6904265
  • 1,938
  • 1
  • 16
  • 21
  • Thank you for your quick response! I've now better understood. But I don't understand your workaround. I'm using the following bean: This is used in – olivmir Nov 01 '16 at 10:46
  • The "bio field exception" occurs when (1) you are using 2.0.3.RELEASE of spring-social-facebook, (2) your facebook app was created after 05/10/2016 (has v2.8 version) and (3) make a call to getUserProfile() api or any other method that cause a rest call to facebook against the url "graph.facebook.com/..."; with "bio" field as query parameter. I cannot exclude that the "bio field exception" can occur in other cases, if you get the same exception in another context, please ask another question with all the related infos (stacktrace, your code, etc). – user6904265 Nov 01 '16 at 12:17
  • Can I create a new facebook app with the older version (2.7 instead of 2.8) of the API ? There are some references for getUserProfile in code I don't have control of i.e. in some dependent jars managed by an other team. I wonder if Facebook will let me create a new app with the older api. I couldn't find a way though. – dozer Nov 14 '16 at 13:52
  • I think you can't, all facebook apps created after 05/10/2016 use v2.8 graph API. Moreover you cannot downgrade an existing facebook app to a previous graph api version. – user6904265 Nov 14 '16 at 16:28
  • An extra information: In 12/2016 spring-social-facebook-3.0.0.M1 has been released. This version solves the problem with the deprecated bio field. – olivmir Feb 28 '17 at 10:31