upload image on facebook ios

前端 未结 1 623
北恋
北恋 2020-12-29 17:56

please help me 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

相关标签:
1条回答
  • 2020-12-29 18:10

    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 讨论(0)
提交回复
热议问题