aporat
aporat

Reputation: 5932

Facebook offline access to albums is possible?

I have an iphone app which post photos into albums of facebook users, and I would like to see the photos that were posted by my app.

My app has the offline_access & stream facebook permissions, but I don't store the facebook user_id or anything about the user. I just have the facebook application key & secret.

Does the facebook api allows me to get a list of users who connected with my app, and more importantly is is possible to get the photos which were posted by my app?

Any guidance either in PHP or objective c would be helpful.

Upvotes: 4

Views: 895

Answers (4)

adamkonrad
adamkonrad

Reputation: 7122

If you requested offline_access permission, you need to save access_token of your users to be able to access Facebook on their behalf.

Upvotes: 1

aporat
aporat

Reputation: 5932

Here's the PHP script i have wrote to grab photos and upload them into dropbox (using the dropbox php sdk):

It was actually much simpler then i originally imagined. not need for the user id.

$app_id = 'xxxxxx';
$app_secret = 'xxxxx';
$photoId = 'xxxxx';
$access_token = 'xxxxx';

try {
    $facebook = new Facebook(array(
      'appId'  => $app_id,
      'secret' => $app_secret,
    ));
} catch (Exception $e) {

}

try {
    $attachment =  array('access_token' => $access_token);
    $photo = $facebook->api($photoId, 'GET', $attachment);
 } catch (Exception $e) {

}

$dropbox = new DropboxUploader('xxxxxxx', 'xxxxxxxx');
$tmpfname = '/tmp/' . $photoId . '.png';

$fp = fopen($tmpfname,'x');
fwrite($fp, file_get_contents($photo['source']));
fclose($fp);

 $dropbox->upload($tmpfname, 'photos/');

unlink($tmpfname);

exit;

Upvotes: 0

bkaid
bkaid

Reputation: 52083

Facebook doesn't have an API to see who has connected to your app or retrieve their access tokens. What you will need to do is update your iphone app so that you are storing those access tokens and user ids on your server. Then you could loop through those tokens and use them to retrieve the users photos.

Upvotes: 1

Julian H. Lam
Julian H. Lam

Reputation: 26134

It's easiest if you store your users' albumIDs in your database, as you are trying to refer to users' stored photos when they are not currently using the application.

It's as simple as looping through the list of album IDs, and then making a /$albumID/photos call to get the photoIDs.

Keep in mind you will need the user_photos permission in addition to offline_access.

Upvotes: 4

Related Questions