查询Facebook可以使用什么版本的Graph API [英] Query Facebook for what version of the Graph API is being used / can be used

查看:99
本文介绍了查询Facebook可以使用什么版本的Graph API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是WordPress插件的作者,利用Facebook Graph API。最近,一些Graph调用失败了新的插件用户(只有新的用户受到影响)。经过一番挖掘之后,我相信我在这里偶然发现: https://developers.facebook.com/docs/apps / version

I'm the author of a Wordpress plugin that leverages the Facebook Graph API. Recently, some Graph calls are failing for new plugin users (only new users are affected). After some digging, I believe I've stumbled on the cause here: https://developers.facebook.com/docs/apps/versions

具体来说,我的应用程序可以调用比当前版本更早的版本一节吗?状态:

In particular, the section "Can my app make calls to versions older than the current version?" states:


一个应用程序可以调用该应用程序创建时的最新版本的API

An app can make calls to the version of the API that was the latest available when the app was created

换句话说,即使我的Graph调用指定了一个显式版本(即 https://graph.facebook.com/v2.0/me ),对于新创建的应用程序,Facebook将忽略v2.0并调用2.1。实际上,一个FQL查询就像:

In other words, even if my Graph calls specify an explicit version (i.e. https://graph.facebook.com/v2.0/me), for newly-created apps, Facebook will simply ignore the "v2.0" and call into 2.1. Indeed, an FQL query like:


https://graph.facebook.com/v2.0/fql?q=(更改为MyQuery)及=的access_token(即为MyToken)

收益:

错误:{
message:(#12)版本v2.1及更高版本的fql已被弃用,
type:OAuthException,
code:12

所以这会导致我的第一个问题:我在这里遗漏了什么?对我来说,这个行为似乎使版本化几乎没有用;无论我的电话是否指定v2.0,Facebook将只会调用该应用程序创建时存在的最新版本。因此,Facebook为Facebook提供的两年时间窗口支持旧的api版本(请参阅 https://developers.facebook.com/docs/应用程序/升级)什么也不做,因为我一直需要支持最新版本,或者新的应用程序的新用户将被破坏。对不起?

So that leads to my first question: Am I missing something here? To me, this behavior seems to make versioning pretty much useless; whether or not my calls specify v2.0, Facebook will just call into the newest version that existed when that app happened to have been created. So the two-year time window Facebook gives for supporting old api versions (see https://developers.facebook.com/docs/apps/upgrading) does nothing, as I always need to support the most-current version the moment it's released (or new users with newly-created apps will be broken). Right?

第二个问题(假设上述是正确的):如何查询Facebook当前正在使用的版本(或可以使用的版本)应用程序吗?既然指定v2.0并不意味着它实际上会使用v2.0,那么发现它是否使用了一个意想不到的版本,至少可以帮助抢占可能出现的错误 - 这将是用户错误报告中包含的有价值的信息。我希望这个信息必须以某种方式存在于access_token中,但是我已经搜索过高低,并且无法弄清楚如何询问这个令牌适用于什么API版本(或者也可能是这是什么API版本应用程序支持或类似)?

Second question (assuming the above is correct): How can I query Facebook for the version that's being used (or rather, available to be used) by the current app? Since specifying v2.0 clearly doesn't mean it'll actually use v2.0, finding out if it's using an unexpected version could at least help preempt possible errors - i.e. it'd be valuable info to include with user bug reports. I expect that this information must somehow be in the access_token, but I've searched high and low and can't figure out how to ask, "What API version does this token apply to" (or perhaps, "What's API versions does this app support," or similar)?

推荐答案

您必须区分API版本和应用程序创建。正如你所说,Facebook继续推出2年后,Facebook就支持旧版本的Graph API。

You have to distinguish between API versions and App creation. As you correctly stated, Facebook supports older versions of the Graph API exactly 2 years after the successor has been announced.

https://developers.facebook.com/docs/apps/versions#howlong 状态


版本将在后续版本发布后两年内不再可用。

A version will no longer be usable two years after the date that the subsequent version is released.


所以如果API版本2.0发布于2014年4月30日,API版本2.1发布于8月7日, 2014年,v2.0将于2016年8月7日到期,两年后发布v2.1。

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

如果您发生了什么调用Graph API,没有指定的版本信息如下:

What happens if you make calls to the Graph API with no specified version information is the following:


未版本化的调用将默认为API的最早可用版本

An unversioned call will default to the oldest available version of the API

意味着您的应用程序是在2014年8月1日创建的,您可以调用v2.0,但不能v1.0。如果您的App是2014年4月1日创建的,那么您可以拨打v1.0(但直到2015年4月30日才可以使用v1.0)。如果您的应用在2014年8月7日之前创建,您将只能调用v2.1,无论您指定为版本。

meaning that it your app was created at August 1st 2014, you'll be able to call v2.0, but not v1.0. If your App was created at April 1st 2014, you'll be able to call v1.0 (but only until v1.0 is deprecated at April 30th 2015). If your App was created later than August 7th 2014, you'll only be able to call v2.1, no matter what you specify as version.

这是在

  • https://developers.facebook.com/docs/apps/versions#unversioned_calls
  • https://developers.facebook.com/docs/apps/versions#calling_older_versions

一个应用程序可以拨打最新版本的API,创建应用程序,以及在创建应用程序后启动的任何较新的,不被废弃的版本。

An app can make calls to the version of the API that was the latest available when the app was created, as well as any newer, un-deprecated versions launched after the app is created.

所以,在换句话说,它总是与您的Facebook应用程序的创建日期更相关,因为这将确定App API版本的应用程序将能够使用

要确定应用程序的创建日期,您可以使用

To determine the creation date of an App, you can use the

/{app_id}?fields=id,creation_time

端点,当相应的App为创建。请参阅 https://developers.facebook.com/docs /graph-api/reference/v2.1/app/#readfields 然后,您可以使用例如PHP或JavaScript将Unix Timestamp转换为日期。

endpoint, which will give you the Unix Timestamp when the respective App was created. See https://developers.facebook.com/docs/graph-api/reference/v2.1/app/#readfields You can then use for example PHP or JavaScript to transform the Unix Timestamp to a date.

这篇关于查询Facebook可以使用什么版本的Graph API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆