2011-06-14 123 views
0

你好,我想設置以下的字典如何使用JSON發佈

{ 
     application =   { 
      id = 136664723060869; 
      name = Iphoneapp; 
     }; 
     caption = "bit.ly"; 
     comments =   { 
      count = 2; 
      data =    (
           { 
        "created_time" = "2011-06-14T07:39:45+0000"; 
        from =      { 
         id = 100001507678574; 
         name = "Widevision Dev"; 
        }; 
        id = "100001507678574_164163733643881_1822049"; 
        likes = 1; 
        message = hi; 
       }, 
           { 
        "created_time" = "2011-06-14T08:17:31+0000"; 
        from =      { 
         id = 100001507678574; 
         name = "Widevision Dev"; 
        }; 
        id = "100001507678574_164163733643881_1822143"; 
        message = hmmm; 
       } 
      ); 
     }; 

關鍵價值觀我要發佈comments ={ data ={ id = , name = }}

我用下面這個

NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:4]; 

[variables setObject:@"Good Afternoon" forKey:@"message"]; 


NSLog(@"%@",variables); 

FbGraphResponse *fb_graph_response = [fbGraph doGraphPost:@"id/comments" withPostVars:variables]; 
NSLog(@"postMeFeedButtonPressed: %@", fb_graph_response.htmlResponse); 

但這並不碼工作....我如何發表評論對象的消息

+0

我看不到您提供的僞JSON和它後面的代碼之間的任何關聯。我不知道你爲什麼期望它能工作。 – 2011-06-14 11:26:12

+0

我想發佈評論在Facebook上使用facebook圖形API。爲此目的,我必須發佈任何消息..我這樣做,但它返回與空 – iProgrammer 2011-06-14 11:28:02

+0

您正在傳遞圖形API相當於'{「消息「:」下午好「,」AFAICT,沒有任何背景。我根本不知道FB API(因此評論與答案),但我猜你已經遺漏了API期望的大量信息。 – 2011-06-14 11:33:47

回答

0

請檢查公司

NSMutableDictionary *comments = [[NSMutableDictionary alloc] init]; 
NSMutableDictionary *data = [[NSMutableDictionary alloc] init]; 
NSMutableDictionary *from = [[NSMutableDictionary alloc] init]; 

[from setObject:@"100001507678574" forKey:@"id"]; 
[from setObject:@"Widevision Dev" forKey:@"name"]; 

[data setObject:from forKey:@"from"]; 


[comments setObject:data forKey:@"comments"]; 


NSLog(@"%@",comments); 

FbGraphResponse *fb_graph_response = [fbGraph doGraphPost:@"id/comments" withPostVars:comments];