首页 > 代码库 > 手机归属地查询

手机归属地查询

      这两天用到手机归属地查询,之前找到一个soap的 100次/24小时 之后再继续使用就要收费。太贵了,还耽误事,后来在群里群主给推荐了一个免费的网站:

传送门

有如下功能: 截图给大家吧 只用到了其中归属地的部分 上点代码大家自行使用吧

 

上代码吧 :能够查询手机号的归属地,省份,等信息很全,希望能够帮到大家:

- (void)manageLocationInformation{    NSError *error;    // 拼接查询字符串    NSString *locationStr = [NSString stringWithFormat:@"%@?app=phone.get&phone=%@&appkey=%@&sign=%@&format=json",kLocationBaseURL,_mobileText.text,kAPPKEY,kSIGN];        NSURL *locationURL = [NSURL URLWithString:locationStr];    NSURLRequest *request = [NSURLRequest requestWithURL:locationURL];    NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];        NSDictionary *locationManage = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];    if (!error) {        if ([[locationManage objectForKey:@"success"] integerValue] == 1) {            NSDictionary *locationInfo = [locationManage objectForKey:@"result"];                        // 运营商            NSString *operators = [locationInfo objectForKey:@"operators"];                        // 详细信息    中国,省份,城市            NSString *informationStr = [locationInfo objectForKey:@"style_simcall"];            NSArray *informationArray = [informationStr componentsSeparatedByString:@","];                        // 省份            NSString *province = informationArray[1];                        // 省份-运营商            NSString *provinceManageStr = [NSString stringWithFormat:@"%@%@",province,operators];            NSLog(@";dalksjdf;las----%@",provinceManageStr);            _provinceManage = provinceManageStr;        }    }}