Page 1 of 1

Sorting results from Facebook Graph API

Posted: Sun Apr 07, 2013 5:30 pm
by Christine Stringfield

I am trying to retrieve a list of Facebook friends, and I would like them to be in alphabetical order. The Facebook Graph API returns an array like so:

{
"data": [
{
"id": "12345",
"name": "Jane Doe"
},
{
"id": "56789",
"name": "Elizabeth Doe"
}
]
}

This is in no apparent order. Any suggestions for how I can sort this?


Sorting results from Facebook Graph API

Posted: Sun Apr 07, 2013 5:33 pm
by maxkatz

Check if Facebook API provides an option to sort the result. The other option would be to sort the resulting data on the client.


Sorting results from Facebook Graph API

Posted: Mon Apr 08, 2013 1:08 am
by Christine Stringfield

I figured it out using the Facebook Query Language:

I have to use the following URL for the REST request:

http://graph.facebook.com/fql?q=SELECT uid, name, pic, is_app_user FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY name