[英]Post image on facebook wall using graph api iphone sdk
我一直在尝试使用facebook graph API在Facebook上发布照片。 验证用户身份后,我正在执行以下操作
NSMutableDictionary *variables = [[NSMutableDictionary alloc]init];
[variables setObject:@"some text" forKey:@"message"];
[variables setObject:@"some link" forKey:@"link"];
[variables setObject:[UIImage imageNamed:@"icon@2x.png"] forKey:@"picture"];
NSString *str = @"me/feed";
NSLog(@"str: %@", str);
FbGraphResponse *resp = [self.fbGraph doGraphPost:str withPostVars:variables];
NSLog(@"resp: %@", resp.htmlResponse);
但是我的应用因抛出异常而崩溃:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: -[UIImage dataUsingEncoding:]: unrecognized selector sent to instance 0x11545140'
因此,有人可以帮助我如何使用图形API将图片以及一些消息发布到Facebook墙上。
使用下面的代码
NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:3];
//create a UIImage (you could use the picture album or camera too)
//UIImage *picture =selectimage.image;
UIImage *picture =[self scaleAndRotateImage:selectimage.image];
FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:picture];
[variables setObject:graph_file forKey:@"file"];
[variables setObject:myPost.text forKey:@"message"];
FbGraphResponse *fb_graph_response = [fbGraph doGraphPost:@"me/photos" withPostVars:variables];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.