Need help in FQL query - facebook

I tried the query on FQL using https://developers.facebook.com/tools/explorer
The command I entered was SELECT message FROM status WHERE uid = me()
But the data returned was limited to 100 entries only. Is there some kind of restriction on the amount of data entered? Is there a way to change this restriction?

You can specify limit to the number of results returned.
The default is 100 as you can see. You should consider using larger limits.
Example: SELECT message FROM status WHERE uid = me() limit 200;

Related

Ambiguity in friend_Count in user table [FQL] [duplicate]

This question already has answers here:
Fetching list of friends in Graph API or FQL - Appears to be missing some friends
(3 answers)
Closed 9 years ago.
I am working on FQL to retrieve the friends count of a particular user.
When i use the query Select friend_count from user where uid = me() I get a number which is different from the count i get from this query i.e select uid2 from friend where uid1= me()
Why is an ambiguity here?
Does friend_count also includes pending requests then?
If yes how can retrieve those UIDs?
Select friend_count from user where uid = me() returned me X and select uid2 from friend where uid1= me() returned me Y.
My X is greater than Y which makes me think if X includes the pendin g requests but i am not able to find (X-Y).
The difference is that friend_count returns the total number of friends, regardless of their privacy settings.
Counting the results of SELECT uid2 FROM friend WHERE uid1= me() may be lower because users who have either restricted their visibility in Settings->Apps->Apps Others Use or have turned off Platform Apps will never be returned in FQL or Graph API queries.

Order BY 2 fields in FQL

I'm trying to sort friends by 2 criterias those who use my app first and has the most number mutual friends with me. Is there any way to sort by 2 fields in FQL?
I've found work around using mutual_friend_count * is_app_user as a sorting criteria, but it works only for app_user = 1 and doesn't perform sorting for those who is 0.
The original query is:
SELECT uid, name, is_app_user, mutual_friend_count
FROM user
WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me()) AND uid != me() ORDER BY (mutual_friend_count * is_app_user) DESC LIMIT 333
Execute in graph API/FQL explorer.
I've found work around using mutual_friend_count * is_app_user as a sorting criteria, but it works only for app_user = 1 and doesn't perform sorting for those who is 0.
Of course it doesn’t, because f.e. 66 * 0 gives the same sorting value as 15 * 0 does.
But assuming no one has a mutual friend count greater than 99999, you could sort by is_app_user * 99999 + mutual_friends_count.
This will give app users a “base value” of 99999, and get the number of mutual friends added. For non-app-users, the base value will still be 0, and get the number of mutual friends added as well.
So app users will have a much higher sort value than non-app-users, and will thereby get ranked first – with the added mutual_friends_count taken into account. Non-app-users will still get ranked by their mutual_friends_count, but only after the app users, because they have a much lower sort value.
The only thing that can be a little tricky, is getting the + sign into the query – it has to be URL-encoded as %2B when passing it to the Graph API Explorer via URL, but it does not show it as part of the query afterwards. But from a look at the result, it seems to be using it in making the query nevertheless:
See example query here.

Facebook fql stream table limit

On facebook API reference for FQL stream table you can find that "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."
But if I use siple query
SELECT message FROM stream WHERE source_id = me() LIMIT 500
I get far more than 50 posts. So is it enough only to use LIMIT to get more than 50 posts?

Query every liked object using FQL

I'm trying to query every object which the user has liked since joining facebook by running this query:
SELECT user_id, object_id, post_id FROM like WHERE user_id=me()
This query runs fine and returns some results, but the number of them is a lot less than I estimated. I tried it on different, real user accounts, and for a friend of mine who has joined facebook around 2006 the number of returned results is still only around 65.
I tried this query through the official javascript sdk and through the graph api explorer which gave identical results.
The documentation doesn't state any limit imposed upon querying the like table.
Is there anything, I should be aware when doing a query on this table?
Thank you very much!
According to this documentation :
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.
Although not explicitly mentioned in the doucmentation for likes, I guess this will be the same limit. So try to add created_time in a where clause.

FQL query: query with multiple stream_id gives too few records

I would like to query public posts from multiple Pages.
My FQL query looks like this:
SELECT post_id, source_id FROM stream WHERE source_id in (157528807603192, 127531603328)
This query returns only about 6 records.
However, if I use the two source_id in two separate query I got more than 20 item for both of them:
SELECT post_id, source_id FROM stream WHERE source_id in = 157528807603192
I couldn't find anything in the documentation stating that if you query multiple source_id you need different permissions.
Can anyone explain me what is happening here?
I've found the answer in the documentation. :(
http://developers.facebook.com/docs/reference/rest/stream.get/
"If you specify only one user ID in the source_ids array, you can
return, at minimum, the last 50 posts from that user's profile stream
(Wall) for the last 180 days (it likely can be more).
If you specify more than one user ID in the source_ids array, you can
return posts in those streams only from the last few days (about one
week)."