3

I'm trying to download all of the photos that I've been tagged in from facebook.

https://graph.facebook.com/me/photos?access_token=blah

Returns a data[] with 15 pictures and a paging object:

'paging': { 'cursors': { 'after': 'afterHash', 'before': 'beforeHash' } }

I expected to see next and previous urls in paging to get at more photos.

Calling: https://graph.facebook.com/me/photos?access_token=blah&type=tagged&after=afterHash returns an empty data[]

Adding &limit=14 to the request returns 14 pictures and the next url that I would expect. Getting that next url only returns 1 picture though, for a total of 15 again.

Further details on the pictures being returned by the api call:

Created Times range from 2013-08-25 to 2015-10-10 5 photos uploaded by friends and tagged, 10 uploaded by myself.

When I look at "/Photos/Photos of You" from my profile page I see many more pictures than are being returned by the API (50+ for 2015, hundreds in years before that). The 15 that are being returned are a mixture of pictures that I have uploaded and those uploaded by friends who then tagged me.

Skrealin
  • 1,114
  • 6
  • 16
  • 32
  • and you are sure you´re not tagged in only 15 photos? – andyrandy Dec 22 '15 at 11:45
  • When I look at "/Photos/Photos of You" from my profile page I see many more pictures than are being returned by the API. The 15 that are being returned are a mixture of pictures that I have uploaded and those uploaded by friends who then tagged me. – Skrealin Dec 22 '15 at 12:09

2 Answers2

2

By default reading from the photos edge includes all photos a person has been tagged in.

Required Permission : user_photos

Referance: https://developers.facebook.com/docs/graph-api/reference/user/photos

You can make following API Call. Because no one tagged in 999,999,999,999,999 Photos.

https://graph.facebook.com/me/photos?fields=images{source}&limit=999999999999999&access_token=xxxxx

You can retrieve all photos which was allowed on Timeline. You can see those from here: https://www.facebook.com/your_username_or_id/photos_of

Here is the sample php code which will get source for all photos using curl:

<?php
$curl = curl_init();
curl_setopt_array($curl,array(
    CURLOPT_RETURNTRANSFER =>1,
    CURLOPT_URL => 'https://graph.facebook.com/me/photos?fields=images{source}&limit=999999999999999&access_token=xxxxx',
    CURLOPT_SSL_VERIFYPEER => false
));
$array = json_decode(curl_exec($curl),true);
curl_close($curl);

for( $i = 0; $i<count($array['data']);$i++) 
{
    echo  $array['data'][$i]['images'][0]['source']."</br>";
}
?>
Puvipavan
  • 289
  • 3
  • 10
  • https://www.facebook.com/your_username_or_id/photos_of shows hundreds of photos, but making the api call you suggested still only returns 15 photos. Any ideas? – Skrealin Dec 28 '15 at 20:57
  • Graph Api Returns Only Public Photos. That mean photo's privacy must set to PUBLIC. Privacy can be controlled by the person who tagged you. – Puvipavan Dec 28 '15 at 21:18
  • Or Your friend must allow that app to his account. If the photo's privacy set to other than public. – Puvipavan Dec 28 '15 at 21:29
0

First of all was your access token requested with the user_photos permission?

Also, as taken from https://developers.facebook.com/docs/graph-api/reference/photo:

A user access token may read a photo that user is tagged in if they have granted the user_photos or user_posts permission. However, in some cases the photo's owner's privacy settings may not allow your application to access it.

Most likely though, you need to ask for all albums (via https://graph.facebook.com/me/albums?access_token=blah) and then in turn ask each of these for all the photos. The 15 photos you are retrieving are the photos from the first ever album created as mentioned in Get all photos of a page using Facebook API

Try it out here: https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Falbums&version=v2.5

Community
  • 1
  • 1
Ross Taylor-Turner
  • 3,687
  • 2
  • 24
  • 33
  • The quote that you posted, does that suggest that a photo owner can have privacy settings that would prevent me from downloading a picture via the api, even if I was tagged in it and it showed up in "/Photos/Photos of You" on my profile page? Asking for albums just shows me albums that I have created, not pictures that other people have tagged me in. – Skrealin Dec 23 '15 at 15:09