在FB Graph API中确定具有ID的对象的类型 [英] Determining type of object with id in FB Graph API
问题描述
是否有一种方法可以确定给定ID https://graph.facebook.com/ID
代表哪种对象.当我在Graph API Explorer工具中请求时,响应中有一个名为type
的字段,该字段可能包含user
,page
,album
,photo
等.但是,当我从浏览器或通过SDK请求相同内容时,作为响应,没有这样的字段,但是其他所有内容都是相同的.而且我不得不猜测我依赖于其他字段的种类是什么:例如,如果有一个字段gender
表示我有user
对象.我认为这是FB Graph API中的错误.有什么解决办法吗?
Is there a way to determine what kind of object is represented by the given ID https://graph.facebook.com/ID
. When I'm requesting this in Graph API Explorer tool, in the response there is a field named type
, that could contain user
, page
, album
, photo
and so on. But when I'm requesting the same from browser or via SDK, in response there is no such field, but everything else is the same. And I have to guess what kind of object I have relying on other fields: for example if there is a field gender
that means that I have user
object. I think this is a bug in FB Graph API. Is there any solution for this?
您可以在屏幕截图上看到差异
You can see the differences on the screenshots
推荐答案
如果您通过在请求中添加metadata
参数来使用Facebook上称为自省"的东西,则可以这样做:
This is possible if you using something Facebook call "introspection" by adding metadata
argument to your request:
GET http://graph.facebook.com/object_id?metadata=1
结果将包含type
字段
这篇关于在FB Graph API中确定具有ID的对象的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!