在FB Graph API中确定具有ID的对象的类型 [英] Determining type of object with id in FB Graph API

查看:74
本文介绍了在FB Graph API中确定具有ID的对象的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以确定给定ID https://graph.facebook.com/ID代表哪种对象.当我在Graph API Explorer工具中请求时,响应中有一个名为type的字段,该字段可能包含userpagealbumphoto等.但是,当我从浏览器或通过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屋!

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