从特定位置获取朋友

时间:2014-06-13 13:28:04

标签: facebook facebook-graph-api facebook-fql

如何使用facebook fql和graph

从特定位置获取好友

我试过fql作为

  SELECT uid FROM user WHERE  current_location   IN ('Chennai','Tamilnadu')   AND uid IN 
   (SELECT uid2 FROM friend WHERE uid1 = me() )

显示

  {
"data": [

  ]
}

我也获得了所有必要的许可

1 个答案:

答案 0 :(得分:0)

首先current_location是一种结构,因此current_location IN ('Chennai','Tamilnadu')无效。 您需要指定结构中的任何字段,即:

current_location.city
current_location.state

第二次,只会找到已授权您的应用的朋友。例如,我的一位来自伦敦的朋友正在使用Graph API Explorer。这是自推出v2.0 Facebook API以来的新功能。 Read more here

所以,这个查询:

SELECT uid, current_location 
  FROM user 
 WHERE current_location.city IN ('London')   
   AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me() )

给出:

{
  "data": [
    {
      "uid": "73221xxx", 
      "current_location": {
        "city": "London", 
        "state": "England", 
        "country": "United Kingdom", 
        "zip": "", 
        "latitude": 51.5072, 
        "longitude": -0.1275, 
        "id": "106078429431815", 
        "name": "London, United Kingdom"
      }
    }
  ]
}