Have to ask for "list" instead of "link." Typo in FQL API or do I misunderstand? - facebook-fql

First, This is not a bug report! I want to make sure this isn't a misunderstanding before I file a bug report (in the appropriate place).
SELECT post_id FROM like WHERE user_id = me() AND object_type = "link"
does not work, but
SELECT post_id FROM like WHERE user_id = me() AND object_type = "list"
returns the links that I have liked.
Am I misunderstanding something or has facebook made a horrible mistake?

Facebook most likely made an error (a bug) as to this date the call with list no longer works
SELECT object_id, post_id FROM like WHERE user_id = me() AND object_type = "link"
is the correct call

Related

Get Facebook Events I don't Own

I am building a site that needs to query Facebook events. I need a list of events I do own, and list of events I don't own. The problem is that querying the Events object via FQL requires that I pass one of the indexable fields. Those are creator, name, and eid. This is fine when I need my events (creator = me()). However, when I need events I don't own I can't seem to use a SQL like statement in (creator <> me()).
Any suggestions on how to do this?
SELECT name,start_time,end_time,location,eid,pic,description FROM event where creator = me() and start_time >= 1370106582
It's not as straightforward as I would like but this query works.
SELECT name,start_time,end_time,location,eid,pic,description FROM event where eid IN
(SELECT eid FROM event_member WHERE uid = {UserId} and inviter and rsvp_status = 'attending')
If you query for event_member by the Users Id the Inviter field with be null for events in which they are the owner. In FQL if you just add 'Where {field}' in a where clause, it returns all the results in which that field's value is not null. I know that's a bit confusing but it works.

Facebook Graph API: How can I search a specific user's statuses for a certain keyword?

I want to be able to search/filter a user's statuses for a certain keyword. I thought I could do something like this:
graph.facebook.com/_user_id_/statuses?q=term
Or even:
graph.facebook.com/_user_id_/search?q=term&type=status
But none of those work and I can't find any documentation on this. I know I can do it with FQL, but the statuses method of the Graph API would give me likes and comments to each status as well.
Any suggestions?
You can do this with FQL, it just takes a multiquery to get it done:
{
'posts_w_keyword': 'SELECT post_id, actor_id, message FROM stream WHERE source_id = me()
AND strpos(message, "keyword") > -1',
'post_comments': 'SELECT post_id, from_id, text FROM comment WHERE post_id IN
(SELECT post_id FROM #posts_w_keyword)',
'post_likes': 'SELECT post_id, user_id FROM like WHERE post_id IN
(SELECT post_id FROM #posts_w_keyword)'
}

How to I get all the checkins a user is tagged in using FQL

Using the graph api it's possible to do:
https://graph.facebook.com/me/checkins
But how am I supposed to do it with FQL?
I tried this which suggests:
SELECT message FROM checkin WHERE author_uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
AND me() IN tagged_uids
but it doesn't return even a single result.
Thanks.
From what I can see, IN doesn't seem to work with me(). You have to first get the user id and assign this to a variable. This throws an OAuth exception:
SELECT message FROM checkin WHERE author_uid = me() OR me() IN tagged_ids
but if you set [UserId] to the current user's id, this works:
SELECT message FROM checkin WHERE author_uid = [UserId] OR [UserId] IN tagged_ids
You don't need to use the friend subquery. FQL will only return checkins that are visible to your user.
For this to work, make sure your access_token has both the user_checkins and friends_checkins permissions.
#cpilko gave a solution, but I've found another one, so I am adding it here as a reference for whoever reach this page:
SELECT id FROM location_post WHERE ([UserId] IN tagged_uids OR author_uid=me()) AND strpos(type,"checkin")>=0

Facebook's fql improper ORDER BY sorting

I have this fql 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())
ORDER BY created_time DESC
LIMIT 0,200;
It's supposed to display last 200 posted links by my friends, but it displays them ordered by owner id ASC then by created_time DESC.
Is ORDER BY in fql limited to one use? How can I make it work?
I suspect the problem is the LIMIT statement. FQL has some odd internal behaviors to optimize their own internal API.
Try removing the LIMIT statement and just give it a specific AND created_time > <point in time> and see if it orders properly. If so, that's why.

FQL query to fetch all feeds by page name

Hie
Can someone please tell me how to fetch all the feeds of a facebook page say "cocacola" using FQL ?
You can use one query something like:
SELECT post_id,message
FROM stream
WHERE source_id IN (
SELECT page_id
FROM page
WHERE name='coca-cola'
) LIMIT 5
BUT it's not recommended searching by name, since it may return more than one page. If you know the page_id use it directly. If you are a fan of the page try querying the page_fan table first.
Why not just use graph:
http://graph.facebook.com/cocacola/feed
[edit]
You could try with 2 query-es, one for getting page id and second for getting stream.
You can even try to combine them using fql.multiquery like this:
"query1":"SELECT page_id FROM page WHERE name='cocacola'"
"query2":"SELECT message FROM page WHERE source_id IN (SELECT page_id FROM #query1)"
SELECT post_id,message
FROM stream
WHERE source_id IN (
SELECT page_id
FROM page
WHERE name='coca-cola'
) and actor_id IN (
SELECT page_id
FROM page
WHERE name='coca-cola'
)