我使用以下代码将图像从iOS上传到Facebook。
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 :(得分: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...");