Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用graph api iphone sdk在facebook墙上发布图像_Iphone_Ios_Facebook Graph Api - Fatal编程技术网

使用graph api iphone sdk在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:@"

我一直在尝试使用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'

因此,有人可以帮助我如何使用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呢。如果我这样做,那就是抛出一个圆弧错误。不管怎样,我都会删除它并直接添加图像。谢谢