zoukankan      html  css  js  c++  java
  • 接口文件的代码

     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"]);

        }];

        

  • 相关阅读:
    前缀和
    不用加减乘除做加法
    数组中重复的数字
    滑动窗口的最大值
    矩阵中的路径
    Redis 和 Memcached 的区别 Tair
    机器人的运动范围
    汉诺塔问题
    洗牌算法
    斐波那契查找算法(黄金分割查找算法)
  • 原文地址:https://www.cnblogs.com/wukun16/p/4851166.html
Copyright © 2011-2022 走看看