Upload image to facebook ios

please help me upload the image to facebook using iphone app.here, I don't have url.i, I just have only the image. But I can not upload it to facebook.if I can use the url, then I can just upload it. Please help me.

send me the code to upload the image. I am already creating an instance of facebook and other codes regarding fbconnect ios.

+5
source share
1 answer

DemoApp, which comes with the facebook iOS api, contains code for uploading photos to a sample:

https://github.com/facebook/facebook-ios-sdk/tree/master/sample/DemoApp

/**
 * Upload a photo.
 */
- (IBAction)uploadPhoto:(id)sender {
  NSString *path = @"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg";
  NSURL *url = [NSURL URLWithString:path];
  NSData *data = [NSData dataWithContentsOfURL:url];
  UIImage *img  = [[UIImage alloc] initWithData:data];

  NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                 img, @"picture",
                                 nil];
  [_facebook requestWithMethodName:@"photos.upload"
                         andParams:params
                     andHttpMethod:@"POST"
                       andDelegate:self];
  [img release];
}
+16
source

All Articles