2015-11-06 84 views
0

我正在使用以下代碼將圖像從iOS上傳到Facebook。iOS FacebookSDK圖像共享

NSMutableDictionary* params = [[NSMutableDictionary alloc] init]; 
[params setObject:@"MY TEST MSG..." forKey:@"message"]; 
[params setObject:UIImagePNGRepresentation(self.editImageView.image) forKey:@"picture"]; 


[[FBSDKGraphRequest alloc] initWithGraphPath:@"me/photos" parameters:params HTTPMethod:@"POST"] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { 
     if (!error) { 
      NSLog(@"uploaded"); 
     } else { 
      NSLog(@"Graph API Error: %@", [error description]); 
     } 
}]; 

我的應用程序被卡住了幾分鐘,並顯示錯誤消息。 任何人都可以幫我嗎?

回答

0
NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:3]; 
UIImage *picture = FilterImage; 
FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:picture]; 
[variables setObject:graph_file forKey:@"file"]; 
[variables setObject:[NSString stringWithFormat:@"Hello testin"] forKey:@"message"]; 
[fbGraph doGraphPost:@"me/photos" withPostVars:variables]; 
NSLog(@"Now log into Facebook and look at your profile & photo albums..."); 
+0

謝謝你的回覆。你能告訴我哪個Facebook包應該導入FbGraphFile? – Rupshikha

+0

最新的facebook軟件包。 – user3182143

+0

我正在使用最近9月發佈的SDK,但我無法理解要導入哪個文件? (如#import ) – Rupshikha