Get all friends' ids who liked a post - facebook-graph-api

I am using Facebook FQL to query stream table. I want to get the list of all user ids of friends who liked one of my post. Here is my query:
select post_id,likes.friends, likes.count from stream where source_id = me() and likes.count > 0 limit 200"
However, I only get maximum 4 friend ids in return, even if likes.count > 4, which is exactly like likes.sample.
Is this a bug, or a limitation of FQL? If I can't get full list of Likers here, which table I should look at? If this is not feasible with FQL, how can I make a similar query in Graph API?
Thank you.

Use a multi-query on the stream and like tables
{"posts": "select post_id, likes.count from stream where source_id = me() and likes.count > 0 limit 200",
"friends_who_like_posts":"select user_id FROM like WHERE post_id IN (SELECT post_id FROM #posts) AND user_id IN (SELECT uid2 FROM friend WHERE uid1 = me() )"
}

Related

Getting all commets for an event with FQL

i am trying to list all comments for an event created by a certain page. I am getting the EID for for the event with a multiquery like this:
{ 'eids':'
SELECT eid, uid
FROM event_member
WHERE uid = 64565465464
'events':'
SELECT eid, name, venue, location, start_time, creator
FROM event WHERE eid
IN (SELECT eid FROM #eids)
AND creator = 64565465464 ORDER BY start_time ASC'}
I am totally clueless how to get the comments for that event with that EID.
Does anyone know how?
You will use the stream FQL table. The source_id on this table relates to the eid of the event table.
Example query via your above multi-query:
SELECT message FROM stream WHERE source_id IN (SELECT eid FROM #eids)
Docs: https://developers.facebook.com/docs/reference/fql/stream

Get right FQL query with location_post table

I am trying to get all posts near specific location. I post some statuces and photos on my FB page with location.
In Graph API Explorer I run this query:
SELECT id, coords, type, page_id, timestamp FROM location_post WHERE author_uid = me()
and it results in right way, but when I add:
SELECT id, coords, type, page_id, timestamp FROM location_post WHERE author_uid = me() AND distance(latitude, longitude, '47', '122') < 10000
then all results cleared.
I tried to get distance in query and it results in nice numbers like 33 or 454. So why distance function in WHERE section results in nothing?
Also request from example:
SELECT id, page_id
FROM location_post
WHERE distance(latitude, longitude, '37.86564', '-122.25061') < 10000
does't show anything.
For the example query, Your lat/long is reported somewhere outside of Oakland, CA. To return data you need one of the following:
If you requested user_location permission in your access token, you need to have made or been tagged in a post made within 10km (~6.25 mi) of this point.
If you requested friends_location permission in your access token, a friend of yours needs to have made this post.

How get friends Check Ins since a date?

So i'm trying to get friends check ins form a specific date up to "now"
Like so:
search?type=checkin&since=1343613333633
(1343613333633 = 30 Jul 2012 01:55:33 GMT)
And I always get {"data":[]}
with out the "since" param i some check ins (all of them after that date)
i get the same results both on graph api explorer and from Android Facebook SDK (not sure if this is important)
How do i fix this?
Thx in advance.
You can easily use FQL to do it:
SELECT coords, tagged_uids, page_id, timestamp FROM checkin WHERE author_uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) and timestamp > 1312971542
will give you the list of friend checkins of the current logged in user since timestamp. Be sure to have the friends_checkins permission when retrieving the access token.

FQL: Trouble joining tables where id is in format USERID_LINKID

I am running the following FQL via the php sdk:
{
"posts" : "SELECT post_id, actor_id, message, type FROM stream WHERE type = '80' AND message != '' AND filter_key in (SELECT filter_key FROM stream_filter WHERE uid='588853265' AND type='newsfeed') AND is_hidden = 0 ORDER BY created_time DESC LIMIT 50",
"actors" : "SELECT uid,name FROM user WHERE uid IN (SELECT actor_id FROM #posts)",
"links" : "SELECT owner, url FROM link WHERE link_id IN (SELECT post_id FROM #posts)"
}
I get results as expected for posts and for actors but not for links (results are empty). I believe the problem is that the link table uses a normal ID but my 'posts' from 'stream' show the ID in the format: USERID_LINKID.
I have played around with substr() and strlen() to get it to work with no luck.
There doesn't seem to be a way to get a link_id from a stream post. Your query is getting the id of the post, but not the link.
However, I don't think you need it. Get rid of the #links sub-query and add attachment to the SELECT statement in your #posts sub-query. You can get the link url at attachment->media->url.
One other critique: You might want to add additional sub-queries for #actors. The actor_id returned by the stream table can be a user, page, or group. Your FQL only resolves users. You'll end up with unknown IDs for links posted by groups and pages.

How to write FQL to fetch news feeds

I have to fetch all data which is on News Feeds (public wall). What query should I write ?
I wrote "SELECT likes,message FROM stream WHERE source_id = %lld limit 50 " query but it is returning my wall value. I want to fetch all data which is on my wall as well as on public (News Feed).
Thanks in advance
You need to use the filter_key to select the type of feed to use. The type you are after would probably be newsfeed, so the query could be something like this:
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')
For more information, have a look at the stream_filter docs.
How about doing it without querying FQL? :)
Use the Graph API instead:
https://graph.facebook.com/me/home?access_token=...
Try it on using "Graph API Explorer". /me/home