我正在尝试向用户的提要发布类似这样的内容(它最初只显示一张图片,但是当您单击“显示更多”时,您会看到所有五张图片)
我的代码如下所示:
NSMutableArray *properties = [[NSMutableArray alloc] initWithCapacity:5];
NSMutableArray *media = [[NSMutableArray alloc] initWithCapacity:5];
for (MyObject *object in self.myObjects) {
[properties addObject:[NSDictionary dictionaryWithObjectsAndKeys:object.name,@"text",
object.link,@"href", nil]];
NSString *imageUrlString = object.url.absoluteString;
[media addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"image",@"type",
imageUrlString,@"src",
object.link,@"href", nil]];
}
NSData *propertyData = [NSJSONSerialization dataWithJSONObject:properties
options:NSJSONWritingPrettyPrinted
error:nil];
NSString *propertiesString = [[NSString alloc] initWithData:propertyData
encoding:NSUTF8StringEncoding];
NSData *mediaData = [NSJSONSerialization dataWithJSONObject:media
options:NSJSONWritingPrettyPrinted
error:nil];
NSString *mediaString = [[NSString alloc] initWithData:mediaData
encoding:NSUTF8StringEncoding];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:myAppID, @"app_id",
link, @"link",
name, @"name",
caption, @"caption",
propertiesString, @"properties",
mediaString, @"media",
description, @"description", nil];
[FBRequestConnection startWithGraphPath:@"me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:completionHandler];
这只会发布一张图片,但我需要发布所有 5 张图片。
编辑:我们已经通过 janrain 参与库在一篇帖子中发布了 5 张图片,所以这是可行的!