在 FB Graph API 中确定具有 id 的对象类型

发布于 2024-12-28 02:47:35 字数 526 浏览 2 评论 0原文

有没有办法确定给定 ID https://graph.facebook.com/ID 代表什么类型的对象。当我在 Graph API Explorer 工具中请求此操作时,响应中有一个名为 type 的字段,其中可能包含 userpage相册照片等。但是当我从浏览器或通过 SDK 请求相同的内容时,响应中没有这样的字段,但其他一切都是相同的。我必须猜测我依赖其他字段的对象类型:例如,如果有一个字段gender,这意味着我有user对象。我认为这是 FB Graph API 中的一个错误。有什么解决办法吗?

您可以在屏幕截图上看到差异 graph api explorer 工具的响应 我的浏览器的响应

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
the response of graph api explorer tool
the response from my browser

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

メ斷腸人バ 2025-01-04 02:47:35

如果您通过在请求中添加 metadata 参数来使用 Facebook 所谓的“内省”,这是可能的:

GET http://graph.facebook.com/object_id?metadata=1

结果将包含 type 字段

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

The result will contain type field

情话已封尘 2025-01-04 02:47:35

您可以添加metadata=1,如果您确实提出这样的请求,响应将包含 metadata: {type: ...}

http://graph.facebook.com/object_id?metadata=1&fields=id,name,metadata{type}

基于 Vinicius Tavares 的推荐。

You can add metadata=1 and response will have metadata: {type: ...} if you do request like that:

http://graph.facebook.com/object_id?metadata=1&fields=id,name,metadata{type}

Based on commend of Vinicius Tavares.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文