使用graph api iphone sdk在facebook墙上发布图像
我一直在尝试使用facebook graph API在facebook上发布一张照片。在验证用户身份后,我将执行以下操作使用graph api iphone sdk在facebook墙上发布图像,iphone,ios,facebook-graph-api,Iphone,Ios,Facebook Graph Api,我一直在尝试使用facebook graph API在facebook上发布一张照片。在验证用户身份后,我将执行以下操作 NSMutableDictionary *variables = [[NSMutableDictionary alloc]init]; [variables setObject:@"some text" forKey:@"message"]; [variables setObject:@"some link" forKey:@"
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'
因此,有人可以帮助我如何使用graph 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];
这是否使用graph APi可能重复?如果是,我在哪里可以找到FBI请求?是的,谢谢,阿曼。这对我来说很好。但是为什么我们需要scaleAndRotateImage呢。如果我这样做,那就是抛出一个圆弧错误。不管怎样,我都会删除它并直接添加图像。谢谢