在Facebook上传图片

问题描述:

将图片上传到Facebook墙上时,图像根本没有在墙上。 我试过了:在Facebook上传图片

[[FBRequest requestWithDelegate:self] call:@"facebook.Users.setStatus" params: 
      params dataParam:UIImagePNGRepresentation(img)]; 

无济于事。

+0

除了Sharekit的任何解决方案吗? – Vani 2011-12-27 11:24:08

+0

更改为@“facebook.photos.upload”图片上传,但在没有参数的专辑中。我想要的是它应该在facebook墙上发布文本(params) – Vani 2011-12-27 11:45:00

图像将进入你的相册和信息关于它在墙上。

NSMutableDictionary *params =[NSMutableDictionary dictionaryWithObjectsAndKeys:@"Testmessage", @"message", imageData, @"picture", nil]; 

[facebook requestWithGraphPath:@"/me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self]; 

可以使用Sharekit做到这一点....

试试这个代码...

-(void)shareOnFacebook { 
     //take screenshot 
      UIImage *image = "Your image"; 

     //for debug purpose the image can be stored to photo album 
     //UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); 

     SHKItem *fbItem = [SHKItem image:image title:@"Check out my Image!"]; 
     [SHKFacebook shareItem:fbItem]; 
    } 

使用sharekit你可以试试下面的代码:

-(IBAction)btnSendToFacebookPressed:(id)sender 
{ 
      NSString *var = [[NSUserDefaults standardUserDefaults] valueForKey:@"IMAGE_INDEX"];//This line may not be useful to you... 

      NSString *imageIndex = [[NSBundle mainBundle] pathForResource:var ofType:@"jpg"]; 

      SHKItem *item = [SHKItem image:[UIImage imageWithContentsOfFile:imageIndex] title:@"Your Title"]; 
      [NSClassFromString(@"SHKFacebook") performSelector:@selector(shareItem:) withObject:item]; 

} 

何乐而不为呢使用Sharekit。

将Sharekit框架添加到您的项目中。

从shkconfig.h文件更改设置。

通过它你可以从facebook->开发技术> apps-生成>创建新的APP-键>生成密钥它传递给shkconfig.h

-(IBAction) tryItOnFb:(id)sender 
{ 

    SHKItem *item = [SHKItem image:[UIImage imageNamed:@"YES.png"]title:@"FB Test"]; 
    [NSClassFromString(@"SHKFacebook") performSelector:@selector(shareItem:) withObject:item]; 
}