objective-ciosfacebook-fqlfql.multiquery

Multiple FQL queries in one


In my project I'm using FacebookSDK, I need to get friends list with pagination, so how can I get friends count and friends list (offset "value", limit 10) in one FQL query?

my queries are:

SELECT friend_count FROM user WHERE uid = me()
SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 10 OFFSET 0

Thanks in advance.


Solution

  • You need to encode your two queries as a JSON object and pass that object as the query to the /fql endpoint:

    {
      'num_friends':'SELECT friend_count FROM user WHERE uid = me()',
      'ten_friends':'SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 10 OFFSET 0'
    }
    

    For specific information on using multiqueries with the iOS SDK, see step 2b of this tutorial