Question

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

First attempt:

  • Query me/home and me/feed in batch request.
  • Problem: querying me/home gives me bad results due to Graph API bugs (showing blocked items and on the contrary not showing some items that should be shown) so I decided to change to FQL which seems to handle it much better.

Second attempt:

  • Use single batch request to query: (1) me/feed directly. (2) fql.query for stream table with filter_key set to 'others'.
  • Problem: Needs to also query for user names because the stream table contains only ids.

Third attempt:

  • Use batch request to query: (1) me/feed directly (2) fql.multiquery for stream table with filter_key set to 'others' and the names table with "WHERE id IN (SELECT actor_id FROM #stream)".
  • Problem: Fails. It returns "Error: batch parameter must be a JSON array" although it is a json array.

Fourth Attempt:

  • Use fql.multiquery to get news feed stream, wall stream and names.
  • Problem: I have no idea how to get a view similar to me/feed using FQL. The best I could get is a list of all my own posts but it doesn't show photos the user is tagged in (so I guess more things are missing).

Appreciate any hints.

Was it helpful?

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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top