Ask Facebook for which version of the Graph API is / can be used

I am the author of a Wordpress plugin that uses the Facebook Graph API. Recently, some Graph calls do not work for new users of plugins (only new users are affected). After some digging, I believe I came across a reason here: https://developers.facebook.com/docs/apps/versions

In particular, the section "Can my application make calls on versions older than the current version?" status:

An application can make calls to the version of the API that was last available when the application was created

In other words, even if my Graph calls indicate an explicit version (ie https://graph.facebook.com/v2.0/me ), for newly created applications, Facebook simply ignores "v2" .0 "and calls in 2.1 Indeed, an FQL query, for example:

https://graph.facebook.com/v2.0/fql?q=(myquery)&access_token=(mytoken)

Productivity:

"error": { "message": "(#12) fql is deprecated for versions v2.1 and higher", "type": "OAuthException", "code": 12

So this leads to my first question: am I missing something? For me, this behavior seems to make version control pretty much worthless; no matter if my calls are v2.0, Facebook will just call the latest version that existed when this application was created. Thus, the two-year-old Facebook window for supporting older versions of api (see https://developers.facebook.com/docs/apps/upgrading ) does nothing, since I always need to support the latest version of the moment (or new users from recently created applications will be broken). Right?

The second question (assuming that this is correct): How can I request Facebook for the version used (or, rather, available for use) in the current application? Since the definition of v2.0 does not explicitly mean that it will actually use v2.0, figuring out whether it can use the unexpected version would at least help to supplant possible errors - i.e. It would be valuable information to include in user error reports. I expect that this information should somehow be in the access_token, but I searched high and low and cannot figure out how to ask: β€œTo which version of the API does this token apply” (or, possibly, β€œIn which versions of the API is this support applications "or similar)?

+5
source share
2 answers

You must distinguish between API versions and application development. As you rightly said, Facebook supports older versions of the Graph API exactly 2 years after the announcement of the successor.

Docs at https://developers.facebook.com/docs/apps/versions#howlong state

The version will no longer be used two years after the release date of the next version.

and

So, if API version 2.0 will be released on April 30, 2014, and API version 2.1 will be released on August 7, 2014, then v2.0 will expire on August 7, 2016, two years after the release of version v2.1.

What happens if you make calls to the Graph API without the specified version information:

The default unversified call will be used for the oldest available version of the API.

means that this application was created on August 1, 2014, you can call v2.0, but not v1.0. If your application was created on April 1, 2014, you can call v1.0 (but only until v1.0 gets installed on April 30, 2015). If your application was created later than August 7, 2014, you can only call v2.1, regardless of what you specify as the version.

This is stated in

An application can make calls to the version of the API that was last available when creating the application, as well as any new, not outdated versions that were launched after the application was created.

Thus, in other words, it was always more relevant at what time your Facebook application was created, because it will determine the version (s) of the Graph API that the application can use

To determine the date the application was created, you can use

 /{app_id}?fields=id,creation_time 

endpoint, which will give you the Unix timestamp when the corresponding application was created. See https://developers.facebook.com/docs/graph-api/reference/v2.1/app/#readfields Then you can use PHP or JavaScript to convert the Unix timestamp to a date.

+7
source

Please note that the ability to check the age of the application has changed slightly. Now this:

/ {APP_ID}? = Fields ID, created_time

Now it also returns the actual timestamp

{"id": "12341234123412341234fake", "created_time": "2011-11-30T21: 00: 56 + 0000"}

An easy way to verify this manually is through the Graph API: https://developers.facebook.com/tools/explorer/

Just select the appropriate application and application token.

+2
source

Source: https://habr.com/ru/post/1200081/


All Articles