当我使用以下内容通过FB.api查询Facebook时:
me/events
返回的JSON对象中的JSON事件数组包含字段“name”,“start_tile”,“end_time”,“location”,“id”和“rsvp_status”的信息。我知道我可以通过解析“id”字段并直接查询单个事件来获取有关其他字段和连接的信息(例如“图片”连接或“所有者”字段),但有没有办法在初始查询,所以我可以避免额外的FB.api调用?
{
"name": "Example Name",
"start_time": "2012-05-04T22:00:00",
"end_time": "2012-05-05T01:00:00",
"location": "Example Location",
"id": "xxxxxxxxxxxx",
"rsvp_status": "attending"
}
答案 0 :(得分:0)
来自https://developers.facebook.com/docs/reference/api/
<强>反思强>
Graph API支持对象的内省,使您可以 在不知道其类型的情况下查看对象具有的所有连接 提前时间。要获取此信息,请将metadata = 1添加到对象 URL和生成的JSON将包含元数据属性 列出给定对象的所有受支持的连接。例如, 您可以看到上面的Developer Garage事件的所有连接 通过提取https://graph.facebook.com/331218348435?metadata=1。那 输出:
{
"name": "Facebook Developer Garage Austin - SXSW Edition",
"metadata": {
"connections": {
"feed": "https://graph.facebook.com/331218348435/feed",
"picture": "https://graph.facebook.com/331218348435/picture",
"invited": "https://graph.facebook.com/331218348435/invited",
"attending": "https://graph.facebook.com/331218348435/attending",
"maybe": "https://graph.facebook.com/331218348435/maybe",
"noreply": "https://graph.facebook.com/331218348435/noreply",
"declined": "https://graph.facebook.com/331218348435/declined"
}
}
}