0

我是 iPhone 应用程序开发的新手。我想从 Facebook 获取用户 ID(我的 ID)。我怎样才能得到身份证?控制台中的输出如下。

谢谢

- (void)request:(FBRequest *)request didLoad:(id)result
{
    NSLog(@"result is %@",result);

}   

控制台中的输出在这里:

 {   
 email = "kestwalg@gmail.com";
"first_name" = Gaurav;
gender = male;
hometown =     {
    id = 1231243212321;
    name = Haridwar;
};
id = 1213213231231;
"last_name" = K;
link = "http://www.facebook.com/kestwal.75";
locale = "en_US";
location =     {
    id = 123123123123;
    name = "New Delhi, India";
};
name = "Gaurav Kestwal";
timezone = "5.5";
"updated_time" = "2012-07-10T06:46:25+0000";
username = "gaur.75";
verified = 1;
work =     (
            {
        employer =             {
            id = 12312312312;
            name = "NKAPs Intellects Noida";
        };
        position =             {
            id = 213123123213;
            name = "iPhone Application Developer";
        };
        "start_date" = "0000-00";
    }
);

}

4

3 回答 3

0

试试看:

- (void)request:(FBRequest *)request didLoad:(id)result {
    NSString *jsonString = [NSString stringWithString:[result JSONRepresentation]];
    NSDictionary *userDict = [jsonString JSONValue];
    // do something with the values in the dictionary...
}  
于 2012-07-18T13:05:45.367 回答
0

实施SBJson

将 json 响应加载到 NSDictionary:

NSDictionary *myDictionary = [myJsonString JSONValue];

然后从字典中读取:

NSString *idString = [myDictionary objectForKey:@"id"];
于 2012-07-18T13:03:01.193 回答
0

你只需要解析它,幸运的是在 iPhone 中有很多方法可以很容易地做到这一点。例如,您可以使用此框架:JSON 框架

于 2012-07-18T13:04:55.597 回答