开发者

upload image on facebook ios

please help me 开发者_StackOverflow中文版to upload image on facebook using iphone app.here i dont have the url.i just only have the image.but i cant upload it on face book.if i can use an url then i can simply upload it.please help me.

please send me the code for upload image. i already create facebook instance and other codes relative to fbconnect ios.


The DemoApp that comes with the facebook ios api contains the code to upload a photo in the 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];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜