Facebook sdk for ios阅读粉丝页面墙

时间:2011-09-02 18:56:15

标签: iphone facebook facebook-graph-api facebook-wall

我想从我的iPhone应用程序中读取我的粉丝页面墙,我该怎么办?

现在我有了解析图api的代码:

-(IBAction)parsing:(id)sender{

    [facebook requestWithGraphPath:@"PAGE_ID/feed" andDelegate:self];

}


- (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response {
    NSLog(@"received response");
}

- (void)request:(FBRequest *)request didLoad:(id)result {
    if ([result isKindOfClass:[NSArray class]]) {
        result = [result objectAtIndex:0];
    }
   // NSArray *data = [result objectForKey:@"data"];
    NSArray *from = [result objectForKey:@"from"];

    if ([result objectForKey:@"from"]) {
        for (NSDictionary *name in from) {
            NSString *myName = [name objectForKey:@"name"];
            [self.label2 setText:myName];
            NSLog(@" Log: ", myName);
    }

但是因为他不解析而无法工作:

我要解析的json文件是:

{
   "data": [
      {
         "id": "105744066144184_231235146928408",
         "from": {
            "name": "Alberto ####",
            "id": "1000013568710###"
         },
         "to": {
            "data": [
               {
                  "name": "########",
                  "category": "News/media",
                  "id": "##########"
               }
            ]
         },
         "message": "\u00e8######################################",
         "type": "status",
         "created_time": "2011-09-02T18:30:59+0000",
         "updated_time": "2011-09-02T18:30:59+0000",
         "likes": {
            "data": [
               {
                  "name": "Luca #####",
                  "id": "###########"
               }
            ],
            "count": 1
         },
         "comments": {
            "count": 0
         }
ecc..

1 个答案:

答案 0 :(得分:0)

我用

 NSArray *list = [result valueForKey:@"data"];
    for (NSDictionary *dic in list) {
        NSLog(@"id : %@",[dic valueForKey:@"id"]);
        NSLog(@"type : %@",[dic valueForKey:@"type"]);
        if ([[dic valueForKey:@"type"] isEqualToString:@"status"]) {
            NSLog(@"- message : %@",[dic valueForKey:@"message"]);
        }else if([[dic valueForKey:@"type"] isEqualToString:@"link"]){
            NSLog(@"- link : %@",[dic valueForKey:@"link"]);
        }else if([[dic valueForKey:@"type"] isEqualToString:@"photo"]){
            NSLog(@"- icon : %@",[dic valueForKey:@"icon"]);
            NSLog(@"- message : %@",[dic valueForKey:@"message"]);
        }
        NSLog(@"------");
    }

adaydesign:)