2011-12-27 131 views
0

將圖片上傳到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

回答

0

圖像將進入你的相冊和信息關於它在牆上。

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

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

可以使用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]; 
    } 
0

使用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]; 

} 
0

何樂而不爲呢使用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]; 
}