Facebook SDK iOS:添加post到feed与图像



我已经知道如何向我的用户提要添加帖子,但目前它需要使用图像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来做这个。我要如何做到这一点,仍然能够使用标题,标题和信息?

将这四行代码替换为以下两行:

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

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

最新更新