I am making an FQL query using the Facebook PHP API, like so:
$stream = $this->facebook->api('fql', array(
"q" => "SELECT post_id, actor_id, message, description, description_tags, type, attachment
FROM stream
WHERE filter_key in (
SELECT filter_key
FROM stream_filter
WHERE uid=me() AND type='newsfeed'
) AND is_hidden = 0"
));
This gives me the user’s news feed. However, this will only provide me with the ID of the actor – I need the actor’s name. (By actor, I mean the author of the story in the news feed.)
I understand that I will need to query the API again to retrieve the name. How do I perform such a multiquery? Using this example, how can I get the actor name?
Most people’s initial reaction would be to suggest a multi-query. However I dont suggest it for the following reason: It is possible you app can already knows the name of the actor.
Let’s say you do lots of these calls to get stream items (one of my production applications does and I’ve got it coded the way I describe). What you don’t want to do is overload the API and make Facebook unhappy with your app id and start reducing your call limits!!
So, what you can do is cache (using memcached, web application cache, database, or other) the user name (as the name to id rarely changes for a give id) based upon the actor_id. This is also valuable to find the to/from ids for other facebook fql objects like comments, likes, etc.