Search code examples
iphonefacebook-graph-apiphotos

How to upload multiple photos to Facebook from within iPhone app?


Is there an API call that we can use to upload multiple photos to Facebook from iPhone app? So far we can do only one at a time.


Solution

  • You will need to use the Facebook Connect API directly: the iOS SDK does not expose this kind of functionality.

    You should have a look at the Publishing section of the Graph Photo API which suggests this URL to upload an image (don't forget to ask for the publish_stream credential):

    POST https://graph.facebook.com/USER_ID/photos
    
    message=[optional description]
    source=[the image's data]
    place=[optional image's location]
    

    With the iOS Facebook Connect SDK that would give us this call, given you have a Facebook instance called facebook and a UIImage instance called image:

    [facebook requestWithMethodName:@"/USER_ID/photos"
                          andParams:[NSDictionary dictionaryWithObjectsAndKeys:
                                     UIImageJPEGRepresentation(image, 0.7), @"source",
                                     @"My puppy is so cute!!!", @"message",
                                     nil]
                      andHttpMethod:@"POST"
                        andDelegate:self];
    

    You can couple this call with batch requests to upload multiple pictures simultaneously.