2011-04-06 110 views
1

我一直在拼命地使用Facebook的Graph API發佈附件到當前用戶的牆上的消息。我已經成功地發佈了一個帶有圖片的POST對象,但是一旦我開始閱讀附件,它就無法工作。就好像它不承認那個財產。使用iPhone SDK發佈帶有Facebook Graph API的附件

這裏是我的代碼示例:

NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys: 
          @"ATT NAME", @"name", 
          @"http://my.web.com", @"href", 
          @"ATT CAPTION", @"caption", 
          @"ATT DESC", @"description", 
          [NSDictionary dictionaryWithObjectsAndKeys: 
          @"property 1", @"PROP1", 
          @"property 2", @"PROP2", 
          nil], @"properties" 
          nil]; 

NSString *attachmentStr = [jsonWriter stringWithObject:attachment]; 

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           @"post", @"type", 
           @"MY MESSAGE", @"message", 
           attachmentStr, @"attachment", 
           nil]; 

[_facebook requestWithGraphPath:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self]; 

這將出版「我的信息」,但沒有別的。我真正需要這種附件的原因是因爲「屬性」元素。

非常感謝!

編輯:我只是想澄清,如果我使用下面的字典爲我的PARAMS而不是上面的一個,它工作得很好。我的問題是,我需要使用「附件」對象的「屬性」屬性進行格式化。這裏是字典:

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           @"post", @"type", 
           @"http://my.web.com/pic.png", @"picture", 
           @"http://my.web.com", @"link", 
           postName, @"name", 
           postCaption, @"caption", 
           postDescription, @"description", 
           postMessage, @"message", 
           nil]; 

回答

2

OK,我發現如何與我流後一起送的屬性。我通過查看實際的Facebook Wall頁面中的html來發現它。事實證明,對於POST對象的參數被認爲是附着所以要做的唯一事情是直接添加的「屬性」屬性設置爲POST參數是這樣的:

NSDictionary *properties = [NSDictionary dictionaryWithObjectsAndKeys: 
          @"property 1", @"PROP1", 
          @"property 2", @"PROP2", 
          nil]; 

NSString *propStr = [jsonWriter stringWithObject:properties]; 


NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
          @"post", @"type", 
          @"http://my.web.com/pic.png", @"picture", 
          @"http://my.web.com", @"link", 
          postName, @"name", 
          postCaption, @"caption", 
          postDescription, @"description", 
          postMessage, @"message", 
          propStr, @"properties", 
          nil]; 

[_facebook requestWithGraphPath:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self]; 

瞧!有效!

0

要發佈FEED你必須使用 「USERID /飼料」

如: [Facebook的requestWithGraphPath:@ 「1231241 /飼料」
andParams:PARAMS
andHttpMethod: @「POST」
andDelegate:self];

關於屬性,我不認爲他們是任何屬性的名稱「屬性」可用於飼料的API。

檢查出在這裏:http://developers.facebook.com/docs/reference/api/photo/

+0

嗨艾比,首先感謝您的回覆。我實際上已經能夠使用「我」發佈。我甚至用這裏描述的基本參數發佈了圖像:http://developers.facebook.com/docs/reference/api/post/這個頁面引用了我猜測的「可選附件」是這裏描述的對象:http ://developers.facebook.com/docs/guides/attachments/在這種情況下,他們確實有一個名爲「properties」的屬性。 – sunshineDev 2011-04-06 19:15:17

+0

我不知道這是否可能爲移動設備。因爲這是一個流式附件,通常支持這些網站。如果我沒有錯,您正在使用FBConnect SDK開發iPhone。 – insomiac 2011-04-06 19:26:02

+0

那麼你想上傳或附加?什麼樣的媒體?音樂,閃光燈還是電影? – insomiac 2011-04-06 19:26:28

相關問題