2011-03-08 72 views
2

我正在使用iOS iOS的Facebook DemoApp示例發佈到我的個人資料。它工作得很好。我的問題是如何添加圖片鏈接到這篇文章?我使用的代碼是:iphone facebook publishToStream問題

- (IBAction)publishStream:(id)sender 
{ 
    SBJSON *jsonWriter = [[SBJSON new] autorelease]; 

    NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys: 
                 @"title",@"text", 
                 @"http://www.link.com/",@"href", 
                 nil], nil]; 

    NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks]; 
    NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys: 
           @"This is a name!", @"name", 
           @"This is a caption!", @"caption", 
           @"http://www.link.com/images/log1.png", @"picture", 
           @"This is a long description that goes on an on.", @"description", 
           @"http://www.link.com", @"href",         
           nil]; 

    NSString *attachmentStr = [jsonWriter stringWithObject:attachment]; 
    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
            kAppId, @"api_key", 
            @"Share on Facebook", @"user_message_prompt", 
            actionLinksStr, @"action_links", 
            attachmentStr, @"attachment", 
            nil];  

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

圖片不會出現。我使用的鏈接是正確的。這個帖子成功了。我如何獲得該圖片鏈接以顯示?

感謝您的幫助。

回答

2

Facebook iOS SDK中的示例應用程序有點過時。我詳細說明了在我對這個SO question的回答中發佈到用戶流和相關文檔頁面的正確方法。