Facebook SDK iOS:将帖子添加到带图片的Feed中

时间:2011-12-05 07:37:08

标签: ios facebook cocoa-touch facebook-graph-api

我已经找到了如何向我的用户Feed添加帖子,但目前需要使用图片网址:

// 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。我该怎么做,仍然可以使用标题,标题和消息?

1 个答案:

答案 0 :(得分:5)

用这两行替换你的四行代码:

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'。 希望我回答你的问题!