Reputation: 30766
I am working on the API for a mobile application, which for the sake of argument is much like Foursquare and Instagram. Both of those applications will allow you to upload photos to your Facebook profile.
These will be added to a "Foursquare Photos" album, which will be made if it does not exist and you see it in your "Albums" area. Every time you add a new image it will become the album cover and you will see it displayed at the start of your album, so that images are in reverse chronological order (newest at the top/left, oldest bottom right).
To set the cover I assumed I could simply do this:
That is my attempt to post an update to the album ID, setting cover_photo
as the photo ID of a file I've just uploaded. I have created the album fine, uploaded the photo fine all using the same access token - so we know it's not scopes (because yes I definitely have user_photos
on the token).
A second approach was to assume this is automatic and try uploading a photo to the "start" of an album using the "position" field, but when I make a POST it seems to be completely ignored:
$photo = $facebook->api("/{$album_id}/photos", 'POST', array(
'access_token' => $token->oauth_token,
'image' => '@'.$filename,
'no_story' => 1,
'position' => 1,
'from' => array(
'id' => $user_opp->user->facebook_uid,
),
));
That uploads the image fine, but puts it at the end of the album, not the start.
So, how the f**k does this work? I've Googled my arse off and got nowhere. Tried the IRC and had no response, tried the Facebook Developer forums and they're down. I don't have any goats to sacrifice but maybe somebody out there knows.
Upvotes: 2
Views: 1378
Reputation: 96306
Every time you add a new image it will become the album cover and you will see it displayed at the start of your album
That should happen automatically. And in my tests, it does.
A second approach was to assume this is automatic and try uploading a photo to the "start" of an album using the "position" field, but when I make a POST it seems to be completely ignored
That was never intended as a parameter for posting new photos, it was only returned when reading an albums photos from the API; and besides,
https://developers.facebook.com/roadmap/#october-2012
Removing position field for photos: The position field in both the photo FQL table as well as the Photo Graph API object will start returning 0 for all photos. The photos connection on an Album object in the Graph API will continue to return photos in the order they appear in the album.
Upvotes: 2