SDK在Facebook墙上发布图片

SDK在Facebook墙上发布图片

本文介绍了使用图API iPhone iPhone SDK在Facebook墙上发布图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用facebook graph API在Facebook上发布照片.验证用户身份后,我将按照以下步骤进行操作

I have been trying to post a photo on facebook using facebook graph API. After authenticating user I am doing as following

        NSMutableDictionary *variables = [[NSMutableDictionary alloc]init];
        [variables setObject:@"some text" forKey:@"message"];
        [variables setObject:@"some link" forKey:@"link"];
        [variables setObject:[UIImage imageNamed:@"[email protected]"] forKey:@"picture"];

        NSString *str = @"me/feed";
        NSLog(@"str: %@", str);
        FbGraphResponse *resp = [self.fbGraph doGraphPost:str withPostVars:variables];
        NSLog(@"resp: %@", resp.htmlResponse);

但是我的应用因抛出异常而崩溃:

But my app crashes by throwing an exception:

    *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: -[UIImage dataUsingEncoding:]: unrecognized selector sent to instance 0x11545140'

所以有人可以帮助我如何使用图形API将图片以及一些消息发布到Facebook墙上.

So some one can help me how do i post an image on Facebook wall along with some message using graph API.

推荐答案

使用下面给出的代码

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];

这篇关于使用图API iPhone iPhone SDK在Facebook墙上发布图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 17:24