Using the Facebook Graph API how can find the most liked photo in an album on one of my pages? - facebook

Using the Facebook Graph API how can find the most liked photo in an album on one of my pages?
I have access to the page insights if that can be used.
There are 200 photos in each album so I don't want to do an api request for each photo.

Subsequently you may also find the most commented on.
Here is the code you request:
http://fivespot.me/fblikes.php
$likes = $facebook->api('/'.$picId.'/likes');
However if you are looking to just find out the most liked there is an app already compiled that will do this for you:
http://apps.facebook.com/imanpic/

The Graph API doesnt support querying for an arbitrary set of photos with some criteria. BUT - you can access the Likes object for each Album, which returns a data set representing all the Liked Photos in that Album. You could then just walk that data set and count the number of times you see the same photo Like.
Thus - you just need to issue a Graph API call for Likes sub-object of an Album.
See "Likes" under "Connections" at:
http://developers.facebook.com/docs/reference/api/album/

Related

How to get the images of a facebook album using graph API

I want to get the links of Facebook photos in albums posted from a page that I am managing. I tried to use facebook graph API. I could get the names and ids of albums via "{page_id}/albums/" . Then I tried to use the album id/?fields=photos{link} to get the link. But here it will provide facebook link (eg:https://www.facebook.com/page_name/photos/a.193909724216/193907241065159/?type=3)
But I want to show this images on a page. So I want the real image path. (eg:https://scontent.fcmb1-1.fna.fbcdn.net/v/t1.0-9/38801583_193907078972459378765588463616_o.jpg?_nc_cat=0&oh=6bdfdfc0cc225a1f035295bb2e2a8&oe=5BF8A013).
Can I get them using Facebook graph API?

Facebook Graph API Pages Albums - Specifying size for the images

I am fetching albums from a Facebook page using the Graph API (v3).
I then process each album individually and request its photos, reaching at the album edge.
/{album-id}?fields=photos{id,images}
Ideally, I would like to find a way to specify a desired size/type (for example thumbnail or width = 640px) for the photos.
Is there any way?
*This question is about the album edge. Answers on questions like:
Facebook Graph API : get larger pictures in one request, or Graph API get photo square (100x100) are not a solution to this question.

Facebook Graph API returns partial results for albums

When pulling photos from a Facebook album via the graph API, i.e.
https://graph.facebook.com/<albumid>/photos?access_token=<token>&limit=999&fields=name,source
For some albums, it only supplies partial results. For instance, an album with 15 photos may only return 13 photos. This call:
https://graph.facebook.com/<albumid>?access_token=<token>&fields=count
...Indeed returns the proper count of 15. My first thought was that perhaps these 2 "missing" photos have more limiting privacy settings, but every photo in the entire album (which is owned by the owner of the token, incidentally) has the same "visible to friends" privacy setting. Most albums do return all photos, as expected.
Any ideas as to what might be causing this behavior?
I was missing 4 photos of 33 for one of my albums. I added 'user_status' to the permissions and it suddenly works.
Instead of the cause of why it happens, I am suggesting you a workaround. Graph api is well known for returning partial results. (You can search for that, and you get hell lot of such issues.)
why not go the FQL way?
Checkout :https://developers.facebook.com/docs/reference/fql/photo/
You can get the id, or direct images links of the pictures in an album in a single query.
Sample : SELECT src_big FROM photo WHERE aid="20531316728_324257"
This returns the url of biggest version of the pictures inside the album.
This should probably solve your problem as long as you are using a user access_token and not app access_token.

Number of likes for a photo or album thru the API

Is it possible to get the number of likes for a photo or album using facebook's API?
This is a link to the open graph for an album
http://graph.facebook.com/99394368305
but it doesn't have the number of likes.
on facebook, you can see it has 2475+ likes
http://www.facebook.com/media/set/?set=a.99394368305.88399.40796308305
thanks
To get the likes for a photo is easy, as you can see in the API Reference:
http://developers.facebook.com/tools/explorer/?method=GET&path=20531316728
For an album you can use the likes connection to get all members who liked that album. So, in your case:
http://graph.facebook.com/99394368305/likes
Notice that that won't return the count. You have to manually go through the results and count the likes. So you should definitely cache the results!
Try to use something like this as the URL to fetch what you need:
https://graph.facebook.com/albumID/photos?fields=id,likes.summary(true),comments.summary(true)&access_token=XXXXXX
Here is a post that explains how in detail.

Is it possible to download all of my photos on facebook through facebook graph api?

I want to download all of my photos and albums from facebook in a programatic way.
I know its possible to push photos to fb through graph api. I was wondering if it is possible to pull photos as well.
Yes. First you would have to get all the albums:
https://graph.facebook.com/me/albums?access_token=
Then you would have to request the list of photos in each album:
https://graph.facebook.com/album_Id_here/photos?access_token=
The result of the last request will give you a JSON object that contains urls of each photo in the album.
See the documentation here: http://developers.facebook.com/docs/reference/api/