Inconsistent Results in FQL Stream Table with IN clause - facebook-graph-api

I'm having issues getting an FQL query to work with an IN clause for multiple pages. The pages are publicly accessible - so I'm not sure if there a permission issue or not
Ex:
SELECT post_id, source_id, message FROM stream WHERE source_id in (40796308305, 56381779049) order by updated_time;
This is using the graph api explorer with all the permissions enabled. I will either get no data, or just simply a few posts from the last graphid specified in the IN clause.
Thoughts? This doesn't seem to be well documented in the FQL documentation.

You can do this as a multiquery. You'll get all your data in one shot. You will need to sort the results together in your script to get these into chronological order.
{
"coke":"SELECT post_id, source_id, message FROM stream WHERE source_id = 40796308305 order by updated_time",
"pepsi":"SELECT post_id, source_id, message FROM stream WHERE source_id = 56381779049 order by updated_time"
}

Related

Getting all links of any sort shared by a user's facebook friends

I am trying to get all links shared by a user's friends I tried all of the queries and requests from the below questions,
How do I get a friend's links with Facebook's graph api?
Finding who shared a link publicly and finding who reshared a given link
Facebook API: All links shared by all friends?
get shared links on facebook newsfeed
but unable to figure out what would be the exact FQL or the request URL to get all links shared from my friends from a defined past interval. I am kind of a newbie with the graph API and FQL, so kindly help me in figuring out a way to do this.
I tried a simple query
SELECT link_id, owner, owner_comment, created_time, title, summary, url, image_urls FROM link WHERE owner IN (SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 100)
but I get
{
"error": "Request failed"
}
as the response from the API Explorer.
Your query is too long for FQL to construct the answer. If you'll try this:
SELECT link_id, owner, owner_comment, created_time, title, summary, url, image_urls
FROM link WHERE owner IN
(SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 10)
(the same query, only limit set to 10 instead of 100) FQL explorer will think ~5-8secs but then give you back the result. Or if you will not receive the result, you have to reduce limit again.
So you have 2 choices:
You can lower you limit from 100 to 10 or less and run your query without changes
You can run query
SELECT uid2 FROM friend WHERE uid1 = me()
and then for each received friend ID run another query
SELECT link_id, owner, owner_comment, created_time, title, summary, url, image_urls
FROM link WHERE owner = FRIEND_ID

FQL query using Facebook Graph API

I have this query:
SELECT uid, name, current_location FROM user WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1 = me() ) AND current_location.id IN (Select current_location.id from user where uid = me() )
It gives me results as required i-e friends only with a particular location.
Can i get the same results using Graph API instead? assuming I have the location id.
I tried this in graph API:
me/friends?location.id='111501225536407'&fields=location
Is something of ^ sort even possible using graph API?
Not that I can see. The Graph API is best for getting all of or the most recent items of an object. If you wanted to filter those friends by location, you would need to do that on the client side.
If you want Facebook to pre-filter your results on their servers, you need to use FQL.
you can execute fql queries (including multiqueries) through the graph api like this:
https://graph.facebook.com/fql?q={"albums":"select aid, name,cover_pid FROM album where owner=me()","album_covers":"select src from photo where pid in (select cover_pid from %23albums)"}&access_token=xxxxxx
It's a little tricky with the url encoding. Be sure that "#" sign used in multiqueries is encoded as %23

FQL does not give all the Friends likes

I am trying to retrieve all my friends' likes using FQL. But I am not getting all the likes only those pages which have "is_community_page" value true are being returned. Here's my FQL query
SELECT uid, page_id FROM page_fan WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
There is a max limit of 5000 results per FQL query that Facebook imposes before the results are trimmed for Privacy preferences of users. You can read this blog post about the same.
Facebook FQL retrieve a link to have full likes list and a samples list (quite unuseful), the point is not the limit of result, the point is fql has a different approach to list this data.
I stepped into it as well, trying to find a solution atm

Calling /me/home/ returns something that is not the same as the user's news feed

Trying to build a news feed app.
I've seen /me/home/ used to get the user's news feed object, but from what I can tell, it returns something similar to the news feed but not exactly the same.
Some posts appear in /me/home/ that are not in the news feed, and a lot of posts that appear is the news feed are not in /me/home/.
Any way to get the same data with graph API?
You can get everything from a user's stream by querying the FQL stream table.
SELECT post_id, actor_id, target_id, message FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed') AND is_hidden = 0
Please read further about the stream at: http://developers.facebook.com/docs/reference/fql/stream/

What is the FQL equivalent of the Graph 'type' field from a /feed call?

I have been using the graph to obtain feed / post information for pages, but have started to use FQL instead as I needed to sort by updated_time rather than the standard created_time sort returned by the graph.
I am using the stream table in FQL and I can get all the information from this I require except the equivalent of the 'type' field (i.e. Status, Link, Photo, Video etc).
When I add type into the fields list for the FQL, I get a int value back (or null) which seems to roughly translate to 46 => page status, 56 => user status, 80 => link ... etc but this field is not documented and this value does not seem to be fully consistent. I've seen a user status be equal to 56 or 237, but not sure what the context difference is to make them change.
The FQL I'm using is:
"SELECT post_id, type, message, description, comments, likes, created_time, updated_time FROM stream WHERE source_id = 40796308305 ORDER BY updated_time DESC" which I'm viewing through the Graph API Explorer /fql?q=
I can get the type information by storing up the ids and making an additional graph call such as "?ids=12345,23456,34567&fields=type" but the goal is to get this in the same call.
Does anybody know how / if this can be achieved?
Many Thanks
This was acknowledged as a bug. See https://developers.facebook.com/bugs/223855374358566