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

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

问题描述

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

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) fql 在 v2.1 及更高版本中被弃用","type": "OAuthException",代码":12

所以这就引出了我的第一个问题:我在这里遗漏了什么吗?对我来说,这种行为似乎让版本控制变得毫无用处;无论我的调用是否指定 v2.0,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 版本和 App 创建.正如您所说的那样,Facebook 在继任者发布后整整 2 年才支持旧版本的 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 版于 2014 年 8 月 7 日发布,那么 v2.0 将在 v2.1 发布两年后的 2016 年 8 月 7 日到期.

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.

如果您在没有指定版本信息的情况下调用图形 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.如果您的应用程序是在 2014 年 4 月 1 日创建的,您将能够调用 v1.0(但仅限于 v1.0 在 2015 年 4 月 30 日被弃用).如果您的 App 是在 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.

概述于

应用可以调用应用创建时最新可用的 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 应用程序的创建日期更相关,因为这将决定应用程序将能够使用的图谱 API 版本

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

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

/{app_id}?fields=id,creation_time

端点,它会在创建相应的应用程序时为您提供 Unix 时间戳.请参阅 https://developers.facebook.com/docs/graph-api/reference/v2.1/app/#readfields 然后您可以使用例如 PHP 或 JavaScript 将 Unix 时间戳转换为日期.

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天全站免登陆