问题
I am developing a iOS app in which i need to support upload multiple photos to Facebook from app.
From many discussed forums and doc, i know that using batch request it is possible.
For the first batch request with multiple photos, the default album is created and added the photos in that album. From next request, all the images those uploaded via batch request are added in that album which is created by default at previous.
So all the images are grouped as a single album. So it is showing only one entry in Facebook timeline.
But i want to show them as separate post instead of a single album entry. For example, if we upload 2 photos from Facebook, it will show as separate entry and so on.
So i need, how to upload multiple photos in Facebook like timeline post not like album post using Facebook iOS SDK?
回答1:
As far as I know you should do the following:
- Create an album programatically via
/{album}
- Upload each photo
/{album}/photo
(https://developers.facebook.com/docs/reference/api/album#photos) - Publish the uploaded photos via
/user/feed
(https://developers.facebook.com/docs/graph-api/reference/user/feed/#publish)
You can use the *object_attachment* field of the latter to link to the individual photo's object id.
回答2:
Well, That's funny because I'm looking for a way to avoid what you want...
If you just do that (I'm using PHP):
$tmp_type = $the_page_id."/photos";
$batch = [
'photo_1' => $fb->request('POST', $tmp_type, [
'message' => 'Foo photo 1 test',
'url' => 'http://www.your_domaine/1.jpg',
]),
'photo_2' => $fb->request('POST', $tmp_type, [
'message' => 'Bar photo 2 test',
'url' => 'http://www.your_domaine/1.jpg',
]),
];
$response = $fb->sendBatchRequest($batch,$the_token_of_the_page);
so if you don't post in an album but directly inside the page (so {page-id}/photos rather than {album-id}/photos), the photos will be saved in the Timeline Album and each photo will produce one entry.
Hope this will help you.
来源:https://stackoverflow.com/questions/21580766/upload-multiple-photos-as-a-single-post-like-timeline-photos-not-like-album-in-f