This FQL query, which used to work, is now returning an OAuthException with code 1 and message "An unknown error has occurred."
SELECT message FROM status WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me())
I have read_stream permission, and the following queries work as expected:
SELECT message FROM status WHERE uid=###
SELECT uid2 FROM friend WHERE uid1=me()
I've also tried adding LIMIT 10 at the end in case there was a timeout issue, but that didn't help.
Do I need additional permissions? Is there an error in the query?
Related
I am attempting to pull the most recent 50 status updates by friends from Facebook using FQL, but it appears the status table nor the feed table work as expected. I am using the following query, but it's results are only the updates since the last Friday # midnight EST (i.e. at the time of this post 12/07/12 # 12AM EST) which is not enough for my need.
SELECT post_id,actor_id,target_id,message,created_time FROM stream WHERE source_id IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND filter_key = "nf" AND created_time > 1 AND type = 46 ORDER BY created_time DESC LIMIT 50
Is there another way to get the most recent 50 status updates from friends that I can use? I have tried the status table, but there are even less results in it.
From http://developers.facebook.com/docs/reference/fql/stream :
Each query of the stream table is limited to the previous 30 days or 50 posts, whichever is greater, however you can use time-specific fields such as created_time along with FQL operators (such as < or >) to retrieve a much greater range of posts.
Try the status table
SELECT message, status_id, uid FROM status WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY time DESC LIMIT 50
You can try this
SELECT message, status_id, uid FROM status WHERE uid IN
(SELECT uid2 FROM friend WHERE uid1 = me())
ORDER BY time DESC LIMIT 50
but be sure to have the friend permissons messege right ;)
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
Hi i am new in using facebook api
i want to get the friends status based on following criteria
Get all the friends details (name, uid, status_message, posted_date) whose status update has more than 15 comments/likes
following query is giving all friends status updates
SELECT status_id, uid , message FROM status WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
Above query returns all my friends updates but i want to include the comments and likes on those updates in the response so that i can check the count on my side
there are comments table and likes table also in the api both might have foreign key relationship with the status_id column
Can we write a full query with joins like SQL
You can't do JOINs in FQL, but you can approximate them with a multiquery:
{
'status': 'SELECT status_id, uid , message FROM status
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())',
'comments': 'SELECT post_id, fromid, time, text FROM comment
WHERE post_id IN (SELECT status_id from #status)'
}
I'm trying to get a list of common likes (public) between a user and his friends. I thought this FQL query would work but I'm getting an unknown user error:
--get page_id that you have and any of your friends have
https://api.facebook.com/method/fql.query?query=
select uid, page_id from page_fan where uid in (SELECT uid2 FROM friend WHERE uid1 = me()) and page_id in (select page_id from page_fan where uid= me())
&access_token=ABC
I'm getting this error:
<error_response><error_code>1</error_code><error_msg>An unknown error occurred</error_msg></error_response>
Any suggestions?
It seems that the result set is way to big for the API to handle. Your best bet is to try to limit the result set by either query a set of friends against the user's like or query one, two ...etc pages at a time (if that also didn't work try to LIMIT your friends to say 100 to make sure you are actually getting something). Example of a query:
select uid, page_id
from page_fan
where uid in (
SELECT uid2
FROM friend
WHERE uid1 = me()
) and page_id in (
select page_id
from page_fan
where uid= me()
LIMIT 1
)
Obviously there is no offset in FQL. So first, you need to retrieve the user's likes and then query against them. You can always use the batch api to make multiple calls in a single batch call.
SELECT page_id from page_fan WHERE uid = me() and page_id IN ( SELECT page_id from page_fan WHERE uid = give one hid here )
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.