Facebook SDK iOS:添加post以提供图片

我已经想出了如何将post添加到我的用户提要中,但是目前需要使用图片url:

// The action links to be shown with the post in the feed NSArray* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys: self.title,@"name",self.url,@"link", nil], nil]; NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks]; // Dialog parameters NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: self.title, @"name", @"Created using My App.", @"caption", @"Check out the thing I just uploaded!", @"description", self.url, @"link", @"http://www.facebookmobileweb.com/hackbook/img/facebook_icon_large.png", @"picture", actionLinksStr, @"actions", nil]; [facebook dialog:@"feed" andParams:params andDelegate:self]; 

我想上传一个UIImage 。 我见过一些人在谈论使用graph api 。 我将如何做到这一点,仍然可以使用标题,标题和消息?

用这两个replace你的四行代码:

 NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:YourUIImage, @"source",@"caption description",@"message", nil]; [facebook requestWithGraphPath:[NSString stringWithFormat:@"/me/photos?access_token=%@", facebook.accessToken] andParams:params andHttpMethod:@"POST" andDelegate:self]; 

和你的UIImage的'YourUIImage'。 希望我回答你的问题!