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

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

Related

How to get all the posts in a Facebook group without a limit.? It only returns 25..?

I have used the call
GroupId?fields=feed{full_picture,place,from,comments{message},message,likes.limit(0).summary(true)}
to get the stated data for my application. But this only returns 25 feeds/posts. I also tried and limit number &limit=number (number like 1000) appending to the above. Yet it returns only 25. How to get all the posts?
Search for "Traversing Paged Results" in the docs:
https://developers.facebook.com/docs/graph-api/using-graph-api#reading
https://developers.facebook.com/docs/php/howto/example_pagination_basic
Some API calls have a max limit, so paging would be the only reliable way to get all items.

How to get shares count for a Photo in Facebook?

I want to get comments count, likes count and shares count for a page posts. I have their IDs and I'm trying to figure something out with the Graph API or FQL, but in vain.
For regular posts I can query the stream FQL table and I get the comment_info, like_info structures and shares_count variable.
For posted photos I can query the photo table and I get from there comment_info and like_info, but it lacks the shares_count.
I tried using Graph api like that: GET /550045508388715 and it returns a ton of information, but nothing related to share count.
I've googled that issue, but did not found any relevant solution.
Instead of GET /ID use GET /POST_ID to get the shares count (if >1). You'll get the result as-
"shares": {
"count": x
}
Note- the Post ID is generally: USERID_PHOTOID ORPAGEID_PHOTOID

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.

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: 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.