2011-06-14 90 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];