facebook batch request to get all the photos - facebook

I want to get all the photos of the user who gave permission to the app. Currently, I tried single and batch request of Graph API but it always paginates the results. Is there a seamless way to get all the objects without following pages?
ps: I'm using PHP-SDK so answering in php is the money :)

I found out that giving limit=0 is solving the problem. It still generates paging object but they return empty data set. So, limit=0 returns the whole dataset in one shot.

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.

page_fans_city returning no results from Graph API

I'm trying to get access to the page_fans_city edge from the Facebook Graph API.
I am using the following query:
https://graph.facebook.com/v2.5/StrandTowerHotel/insights/page_fans_city/lifetime
For some reason though it keeps returning no data when I am using the Graph API explorer.
note: I am an admin/owner of the page
Whats interesting though is that if I just query https://graph.facebook.com/v2.5/StrandTowerHotel/insights/ then I get all the other metrics results returned but "page_fans_city" is not in the results.
I have read through and tried the following solutions already posted on stack overflow but they don't seem to solve the issue.
Getting number of people who like a page on facebook by city
Facebook PHP Graph API not returning complete data
facebook: permanent Page Access Token?
Many thanks in advance for any help you can give me
After much searching and bug fixing it ended up being the facebook api was just having issues. now working perfectly :(

How to get all user's likes using facebook's graph API

How can I query facebook's graph API to retrieve all user's likes (not only pages but also photos and others)?
For instance, how could I get all the pictures a user has liked? Using facebook's search bar you can find them easily by clicking on "photos has liked".
I wrote a script that scrapes the page content and does that but it's not very efficient.
I have recently come accross a similar problem, maybe this helps you solve it.
https://graph.facebook.com/v2.5/{page_id}/feed?fields=likes.limit(1).summary(true)&since={start_date}&until={end_date}&access_token={access_token}
This will give you a list of all posts that received likes during the specified time period. If you manage to write a code summing up the following JSON path you got your sum for "all user's likes":
data[0].likes.summary.total_count
Not entirely sure is this is exactly what you were searching for, hope it helps you though - and if not you, someone else.
As for likes you can also use the same way to extract Shares and Comments:
Shares
https://graph.facebook.com/v2.5/{page_id}/feed?fields=shares&since={start_date}&until={end_date}&access_token=
Comments
https://graph.facebook.com/v2.5/{page_id}/feed?fields=comments.limit(1).summary(true)&since={start_date}&until={end_date}&access_token=
Best regards
There isn't to my knowledge any way to get this from the API without grabbing every type of response from the API and then sorting through for likes. Facebook search bar uses an internal API different from the Graph API.

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.

Getting the large picture in search results with Facebook Graph API

In Facebook Graph API, I'm trying to get the large picture of each user in a search result. The following call will give me the small picture of each user:
https://graph.facebook.com/search?q=Bob%20Grossman&fields=name,id,picture&limit=10&type=user&access_token=*
It's rather easy to get the large picture for a single user, by adding the type=large parameter. But that seems to be ignored when searching (probably since there's already a 'type' parameter used to filter the search results).
Is there any way I can do it with Graph API?
Thanks!
My approach was to pre-fetch all users with the large and square pictures so that I can choose to use either. As far as I know, you cannot do this with the Graph API because the Graph API is pre-defined to present a specific output.
Let me know if you need more information around this.