Skip to content Skip to sidebar Skip to footer

Fql Query To Get The Immediate Family (name, Birthday And Relationship)

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 ui

Solution 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.

Solution 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.

Post a Comment for "Fql Query To Get The Immediate Family (name, Birthday And Relationship)"