2012-04-16 25 views
0

在Facebook上的文档的查看他们写道:与IDS和领域图形API使用选择一起


“默认情况下,当你犯了一个查询最对象属性返回您可以选择字段(或。例如,该URL将只返回Ben的ID,名称和图片:https://graph.facebook.com/bgolub?fields=id,name,picture

您还可以使用“ID”在一个查询中请求多个对象“查询参数,例如,URL https://graph.facebook.com?ids=arjun,vernal以相同的响应返回两个配置文件。”


有没有办法一起使用“?fields”和“?id”?

含义,在一个请求中获得5个特定帖子ID,只有2-3个字段。

谢谢。

回答

6

是的,这是可能的。你可以做这样的事情:

&ids=<some_friends_id>,<some_other_friends_id>&fields=id,name,email,cover 

的问题是,它返回一个巨大的“元数据”的对象,以及 - 我还没有想出如何避免 - 这将浪费带宽。

1

或者它出现,您可以使用批处理请求作为记录在这里:https://developers.facebook.com/docs/reference/api/batch/

例如范例网址提供:

https://graph.facebook.com?access_token=XXX&batch=[{"method":"POST","relative_url":"me/feed","body":"message=Test status update&link=https://developers.facebook.com/"},{ "method":"GET","relative_url":"me/feed?limit=1"}]' 

或者细分:

https://graph.facebook.com? 
    access_token=XXX& 
    batch=[ 
     { 
      "method":"POST", 
      "relative_url":"me/feed", 
      "body":"message=Test status update&link=https://developers.facebook.com/" 
     },{ 
      "method":"GET", 
      "relative_url":"me/feed?limit=1" 
     } 
    ] 

我才刚刚试验这个我自己,但是我最初的研究结果表明你被迫通过POST提交,我认为这是有道理的,但它也是一个小提琴y用于测试地址栏中的查询,并且与Graph API Explorer不兼容。