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 开发者_C百科posted by my app?
Any guidance either in PHP or objective c would be helpful.
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.
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.
If you requested offline_access
permission, you need to save access_token
of your users to be able to access Facebook on their behalf.
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;
精彩评论