Search code examples
ruby-on-railsfacebookfacebook-graph-apikoala

How to order friends using koala gem?


I'm fetching my friends using the Koala gem for Rails framework like that:

@friends = current_user.facebook.get_connections("me", "friends?fields=id,name,picture.type(small)")

The question is: how do I fetch my friends ordered by name, for example ?


Solution

  • Use FQL or post process it in Ruby.

    So for FQL in Koala, something like

    current_user.facebook.fql_query(my_fql_query)

    Where my_fql_query is

    SELECT uid, name, pic_small FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY name