apifacebook-graph-apifacebook-fqlfacebook-batch-request

A way to query both news feed and wall using a single request


I'm trying to find the best way to query both news feed and wall using a single request.

First attempt:

Second attempt:

Third attempt:

Fourth Attempt:

Appreciate any hints.


Solution

  • Due to FQL not doing SQL style joins, getting information from multiple tables in one query is currently impossible.

    1. Use FQL on the stream table to get the list of posts you want to display be sure to grab the source_id. The source_id can be a user id, page id, event id, group id, and there may be more objects too, just don't remember off the top of my head. (You may also want to do similar caching of the actor_id, target_id and viewer_id)
    2. Cache the source_ids in a dictionary style data cache with source_id being the PK.
    3. Loop thru the cache for ones you don't have information on
    4. Try grabbing the information from the user table based upon id, then next the page table, then event table, and group table until you can find what that ID belongs to. Store the information in your cache
    5. For display merge together the stream table items with the source_id information.