Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload multiple photos on Facebook using Batch Request

Tags:

I had done following code with reference to following link to create batch request for uploading multiple photos in Facebook.

I had got some solution for uploading multiple photos on Facebook through this Facebook graph API.

CODE:

    NSString *jsonRequest1 = @"{ \"method\": \"POST\", \"relative_url\": \"me/photos\" , \"body\": \"Hello 1\", \"attached_files\": \"file1\" }";     NSString *jsonRequest2 = @"{ \"method\": \"POST\", \"relative_url\": \"me/photos\" , \"body\": \"Hello 2\", \"attached_files\": \"file2\" }";     NSString *jsonRequestsArray = [NSString stringWithFormat:@"[ %@, %@ ]", jsonRequest1, jsonRequest2];     NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:jsonRequestsArray,@"batch",nil];     [params setObject:UIImagePNGRepresentation(self.image1) forKey:@"file1"];     [params setObject:UIImagePNGRepresentation(self.image2) forKey:@"file2"];     [objFacebook requestWithGraphPath:@"me" andParams:params andHttpMethod:@"POST" andDelegate:self]; 

Now when I am running this code I got the following output.

Result Dictionary in - (void)request:(FBRequest *)request didLoad:(id)result

(         {         body = "{\"error\":0,\"error_description\":\"File file1 has not been attached\"}";         code = 400;         headers =         (                         {                 name = "HTTP/1.1";                 value = "400 Bad Request";             },                         {                 name = "Content-Type";                 value = "text/javascript; charset=UTF-8";             }         );     },         {         body = "{\"error\":0,\"error_description\":\"File file2 has not been attached\"}";         code = 400;         headers =         (                         {                 name = "HTTP/1.1";                 value = "400 Bad Request";             },                         {                 name = "Content-Type";                 value = "text/javascript; charset=UTF-8";             }         );     } ) 

I don't know how this files attached.. Can anyone help me to figure out this problem.

Is there any change in my code then please let me know.

Thanks in advance...

like image 952
Mehul Mistri Avatar asked Apr 24 '12 04:04

Mehul Mistri


People also ask

How do I upload multiple photos at once to Facebook?

Select Photo/Video Album at the top of the update box. Navigate through your computer's drive and select images you want to post. To select multiple images, hold down the Shift or Command key on a Mac, or the Ctrl key on a PC, while you select multiple images to post to the album. Each image should be highlighted.

How do I post multiple pictures on Facebook 2022?

Open Facebook and click the "+" to create a new story. Then, you should see the photo gallery, click on the Select Multiple button. Choose the photos you want to post one by one and click "Next". Then, you can preview your photos and edit each photo freely.

How many photos can you upload to Facebook in a single post 2022?

Share Up to 10 Photos and Videos in One Ad or Post.

How many photos can you post at once on FB?

Note: You can upload up to 1000 photos to an album.


1 Answers

I recommend you use the new integrated Facebook API's in iOS 6 to do this instead of Facebook's API: https://developer.apple.com/videos/wwdc/2012/?id=306 there's a golden WWDC video for all social tasks. Plus using the new API's in iOS 6 is MUCH faster then using Facebooks.

like image 177
ManOx Avatar answered Sep 22 '22 19:09

ManOx