在 FB Graph API 中确定具有 id 的对象类型
有没有办法确定给定 ID https://graph.facebook.com/ID
代表什么类型的对象。当我在 Graph API Explorer 工具中请求此操作时,响应中有一个名为 type
的字段,其中可能包含 user
、page
、 相册
、照片
等。但是当我从浏览器或通过 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您通过在请求中添加
metadata
参数来使用 Facebook 所谓的“内省”,这是可能的:结果将包含
type
字段This is possible if you using something Facebook call "introspection" by adding
metadata
argument to your request:The result will contain
type
field您可以添加metadata=1,如果您确实提出这样的请求,响应将包含
metadata: {type: ...}
:基于 Vinicius Tavares 的推荐。
You can add metadata=1 and response will have
metadata: {type: ...}
if you do request like that:Based on commend of Vinicius Tavares.