FQL查询来获取直系亲属(姓名,生日和关系)(FQL query to get the Immedi

2019-10-28 20:09发布

我试图让从Facebook FQL使用我的直系亲属数据。 我跑这条语句:

SELECT first_name, middle_name, last_name, birthday_date 
from user 
where uid IN (SELECT uid 
              FROM family 
              WHERE profile_id = me() 
              and (relationship = 'brother' 
                   or relationship = 'sister' 
                   or relationship = 'father' 
                   or relationship = 'mother' 
                   or relationship = 'son' 
                   or relationship = 'daughter' 
                   or relationship = 'wife' 
                   or relationship = 'husband'))

但我想也有数据的relatioship。 它给我的只有FIRST_NAME,middle_name,姓氏,birthday_date

Answer 1:

你必须做一个得到这个数据,你需要做的FQL多查询:

{"my_family": "SELECT uid, relationship FROM family WHERE profile_id = me() AND
       (relationship = 'brother' OR ...)".
"family_details": "SELECT first_name, middle_name, last_name, birthday_date FROM
       user WHERE uid IN (SELECT uid FROM #my_family)"}

你需要加入两个结果对象一起uid在你的脚本。



Answer 2:

你需要使用FQL? 现在有,让你正是你一气呵成需要的嵌套字段图API语法:

https://graph.facebook.com/me?fields=id,name,family.fields(first_name,middle_name,last_name,birthday)

其结果是再嵌套JSON对象与关系领域,你需要 - 是这样的:

{
  "id": "738229837", 
  "name": "James Pearce", 
  "family": {
    "data": [
      {
        "first_name": "Bob", 
        "last_name": "Pearce", 
        "birthday": "09/21/1965", 
        "id": "12345", 
        "relationship": "cousin"
      }, 
      {
        "first_name": "Clara", 
        "last_name": "Pearce", 
        "birthday": "12/08", 
        "id": "67890", 
        "relationship": "mother"
      }
      ...
    ], 
    "paging": {
      "next": "https://graph.facebook.com/..."
    }
  }
}

希望帮助。 玩得开心。



文章来源: FQL query to get the Immediate family (name, birthday and relationship)