Query every liked object using FQL - facebook

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.

Related

Searching in FQL query returns only few results instead of 400~

I did this query: SELECT id, username, name, pic_square FROM profile WHERE contains('Restaurants in Vilnius, Lithuania'), as a result I got only 23 results. Hovewer if I search for Restaurants in Vilnius, Lithuania search box, in facebook, I get around 200-400 results. Why is that so ?
Facebook limits the API result to 25 items max and you need to use paging to get the next batch: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#paging
You really shouldn´t use FQL anymore, it will be gone for good after August 2016. Always use the Graph API: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#search

Search Facebook Graph API for long posts?

Is it possible to search the Graph API for posts a Facebook member has written where post.length > n ?
Or would I have to pull posts and parse/filter them in my code?
You can use FQL to make filtered Graph API calls.
This query will get you posts with a message containing the word "this" which are more than 50 characters long.
SELECT message, post_id FROM stream WHERE CONTAINS("this") and strlen(message) > 50 LIMIT 100
The CONTAINS() function is not documented. From my experimentation with it, it searches multiple fields and is optimized to return matches that are based on full names.

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?

FQL query on stream table returns empty using created_time

I have a FQL query for the stream table as follows
SELECT post_id FROM stream WHERE filter_key ='nf' AND created_time < 1335500000
Where the filter_key grabs the news feed. This query returns no data (for my account)
Where as, this query (using unix set at April 30 2012)
SELECT post_id FROM stream WHERE filter_key ='nf' AND created_time < 1335758400
Returns data.
I can keep pushing the unix time back to a point until it just stops showing data, yet there is data there from just browsing my news feed manually through the Facebook UI.
The stream docs state
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.
So to me, it means I can do "pagination" with created_time and limit.
This isn't the case.
Even using the alternative /me/home returns the first set but when I use the pagination links there is no data returned.
Is there something I missing here? Maybe some explanation as to why the previous data is empty for both the FQL and Graph API calls?

FQL query: How to select users from the same country

How do I write the FQL query to select users from the same country?
As hometown_location is not indexable, we cannot use hometown_location as the index.
So, how to do that?
You could (if it wasn't an excessive number of users that you were querying) just get all of them with their hometown_location attribute and then filter it yourself.
If you've already noticed that FQL won't let you compare using that column, then you will need to load each of the user's info you are looking at comparing into some array in your code. Then loop thru that array comparing the hometown_location.