Iphone Facebook API附加照片到贴墙

时间:2011-04-10 23:02:06

标签: iphone facebook

我在使用此代码时遇到问题,以便使用Facebook API在我的帖子中包含照片:

    NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
                                                       @"FSM",@"text",@"www.me.com",@"href", nil], nil];

NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];


NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
                            @"I'm going to:", @"name",
                            @"IMG URL", @"picture", 
                            self.reservation.evento.name, @"caption",
                            self.reservation.evento.date, @"description",
                            @"www.me.com", @"href",
                            nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               kAppId, @"api_key",
                               @"Compartir en FB",  @"user_message_prompt",
                               actionLinksStr, @"action_links",
                               attachmentStr, @"attachment",
                               nil];

[_facebook dialog: @"stream.publish" andParams: params andDelegate:self];

除了照片没有显示在帖子中外,一切正常。

有什么想法吗?

由于

1 个答案:

答案 0 :(得分:1)

根据the docs,流附件中似乎没有“图片”字段。而不是“图片”字段,似乎你应该有一个“媒体”字段,如

"media" : [
    { 
        "type": "image", 
        "src": "http://icanhascheezburger.files.wordpress.com/2009/03/funny-pictures-kitten-finished-his-milk-and-wants-a-cookie.jpg", 
        "href": "http://icanhascheezburger.com/2009/03/30/funny-pictures-awlll-gone-cookie-now/"
    }
]