首页 > 其他 > 详细

接口文件的代码

时间:2015-10-01 17:54:07      阅读:149      评论:0      收藏:0      [点我收藏+]

 NSString *str = @"http://apis.baidu.com/apistore/mobilephoneservice/mobilephone";

    NSString *telStr = @"tel=18798819422";

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",str,telStr]];

    

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

    

    request.HTTPMethod = @"GET";

    

    [request addValue:@"c5a7d13d3e78d6ebebd957262dd39d80" forHTTPHeaderField:@"apikey"];

    

    NSOperationQueue *queue = [[NSOperationQueue alloc]init];

    [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {

        

        //        NSLog(@"%@",data);

        

        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];

        NSLog(@"%@",dic);

        NSLog(@"%@",dic[@"retData"][@"carrier"]);

        NSLog(@"%@",dic[@"retData"][@"province"]);

        NSLog(@"%@",dic[@"retData"][@"telString"]);

    }];

    

 

接口文件的代码

原文:http://www.cnblogs.com/wukun16/p/4851166.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!