Getting less than expected results using facebook graph api - facebook

i am getting post or feed results using the webservice
$jsonStr = file_get_contents('https://graph.facebook.com/'.$fbName.'/posts?access_token='.$accessToken.'&limit=30');
what I notice though is that if I set the limit to 30.. i seem to get about two results.
if i set to 500, i will get maybe.. 80? and the load time will be significantly longer. Is this because it's only showing me the public posts but querying all of them? I would like to show as many posts as possible while keeping the load time to a minimum..

Facebook Graph API uses paging for the bigger results. You should read about the paging API of the Facebook Graph API. Most of the case, because of the paging , facebook API returns fewer results.
Facebook Graph API Paging

Related

No next url for getting instagram medias on facebook's graph API for business accounts

I am trying to fetch all of my instagram page's posts (around 57k posts) from facebook's graph API. using the 'media' endpoint described here:
https://developers.facebook.com/docs/instagram-api/getting-started
I have managed to get around 12k posts using it using the query below:
https://graph.facebook.com/v3.3/{ig-user-id}/media?access_token=XXX&pretty=0&fields=timestamp,caption,comments_count,like_count,media_type,media_url,owner,permalink,shortcode,thumbnail_url,username&limit=200
when using this link returning result contains a data part which is for posts' data and a pagination section which includes next and previous urls and cursors for after and before. I used next and got remaining posts each time, until the result didn't have a next url but it had an after cursor but when I used it the data returned was empty.
I thought there might be some kind of limitation, but couldn't find anything so far except for the API rate limits which I don't exceed.
I also tried the graph API explorer and got the same result.
The problem was not solved but I found something I hadn't seen before, it might help people confused like me.
in the endpoint documentation it is declared that this endpoint has a 10k recent posts limitation, therefor we cannot get any more of our posts.

getting user likes in facebook

I am trying to get user likes in facebook. I can only get 100 at a time for some reason. i tried using the limit parameter in open graph syntax and it didn't help. I alwso tried writing an FQL query to get more likes and to no avail. No matter what I do, i get only 100 likes per request. It's even worse. Most of the likes are of no interest to me. I'm using only likes on several categories. if i could have gotten (using FQL) 100 likes of a user which are all of those categories, that would have been sufficient to me. But when I call the FQL query it seems that FB is querying on 100 first likes and returning the results instead of returning 100 results. I am despaired at this mechanism, is there a way out of this or is FB really gave no way to get more likes in a single call?
Read about paging in the docs: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2?locale=en_GB#paging
I guess the max limit is 100, if you want to get more than that you have to make another call by using paging. There is no way to filter with the API, you will have to do that on your own after getting the likes.

What is facebook's Page / Checkin Pagination limit on search?

I can't seem to find it in the documentation anywhere, and only seem to return 50 results when querying.
https://graph.facebook.com/search?q=coffee&type=place&limit=100&offset=200
Any and all requests to Facebook's API has a default limit of 50. You can add a limit=X parameter to any request you make to the Graph API.
For example, to get 300 results from a users feed, you would use something like this:
https://graph.facebook.com/USER_ID/feed?limit=300

Graph API's search returning considerately less public posts than Facebook's user facing search?

I'm developing an application based on facebook's data using the Graph API. Part of the functionality entails searching Facebook's public post, essentially in the same fashion that Facebook does on www.facebook.com/search:
http://www.facebook.com/search/results.php?q=thanksgiving&type=eposts&init=quick&tas=0.31611707084812224
However, when I issue the same search via the Graph API, the results return miss many of the posts shown in the standard user interface. Many of the most recent posts returned by the standard search are missing (replace the access_token to the one you have):
https://graph.facebook.com/search?q=thanksgiving&type=post&access_token=XXXX
Does anyone have an idea what can cause this and how I can work around it? I have customer questioning the quality of my application because of this difference.
Many thanks,
Boaz
That is because the Graph API uses pagination if it returns too many objects, if you take a look on the bottom of the response of the "Nike" search you will find this:
"paging": {
"previous": "https://graph.facebook.com/search?q=nike&type=post&access_token=XX&limit=25&since=1322257702&__previous=1",
"next": "https://graph.facebook.com/search?q=nike&type=post&access_token=XX&limit=25&until=1322246079"
}
Just make another request to the "next" url in order to fetch more results.

Getting more than 25 photos from the Facebook Graph API

I'm trying to retrieve all the photos a user is tagged in using the Graph API but I can only get the latest 25.
Is it possible to get more, and if so, how?
Have you tried adding a limit and offset parameters? Quoting the documentation:
Paging
When querying connections, there are several useful parameters that enable you to filter and page through connection data:
limit, offset: https://graph.facebook.com/me/likes?limit=3
until, since (a unix timestamp or any date accepted by strtotime): https://graph.facebook.com/search?until=yesterday&q=orange
Currently there is 100 items limitation per query both on photos and likes:
However, 100 pics query takes so much time to run for me.
The following API call:
https://graph.facebook.com/me/photos?limit=500
gives only 100 results with paging link.
Run in FQL explorer (If you have more than 100 pic on your account):
https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fphotos%3Flimit%3D500
Setting limit=0 may not always work in the case that a user has a huge number of tagged photos. Also note that the tagged photos graph API can return a large number of embedded comments as well, so especially if you are developing a mobile app, it can take a long time to return all the photo data. Finally I find that sometimes Facebook will limit the number of entries it can return in times of high load.
So... perhaps the best way is to use the "paging" "next" url that appears at the end of the returned photo data. This gives you the next graphAPI call that you can then use to get the next x photos. It does this by using and pre-populating the limit and until parameters and incorporating them within the graph api call. Very handy.