问题
I trying to get my immediate family data from facebook using FQL. I run this statement:
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'))
But I want to have also the relatioship in the data. It gives me only first_name, middle_name, last_name, birthday_date
回答1:
You have to do a to get this data, you need to do an FQL multi-query:
{"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)"}
You'll need to join the two result objects together on uid
in your script.
回答2:
Do you need to use FQL? There is now a nested field Graph API syntax that gets you exactly what you need in one go:
https://graph.facebook.com/me?fields=id,name,family.fields(first_name,middle_name,last_name,birthday)
The result is then a nested JSON object with the relationship field as you require - something like:
{
"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/..."
}
}
}
Hope that helps. Have fun.
来源:https://stackoverflow.com/questions/12965159/fql-query-to-get-the-immediate-family-name-birthday-and-relationship