iOS开发之百度免费API使用案例(身份证号获取地址、手机号查归属地、MD5解密等)
来源:互联网 发布:动漫图软件 编辑:程序博客网 时间:2024/05/18 03:57
先附上百度APIStore的地址:APIStore
下面是其中几个使用案例:考虑到我的博客看的人比较少,里面的apikey就不隐藏了。万一有一天如果apikey使用频率过高被封了,请自行去百度APIStore申请
(身份证号码这俩,不太严谨,不能判断出生日期是否正确,只能解析出所在省市区,和判断最后一位校验码)
#import "ViewController.h"#import "AFNetworking.h"#define index 7@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; #if index == 1// 天气 NSString *httpUrl = @"http://apis.baidu.com/heweather/weather/free"; NSString *httpArg = @"city=beijing";#elif index == 2// 身份证 NSString *httpUrl = @"http://apis.baidu.com/apistore/idservice/id"; NSString *httpArg = @"id=511702188000111114";#elif index == 3// 生成二维码 NSString *httpUrl = @"http://apis.baidu.com/3023/qr/qrcode"; NSString *httpArg = @"qr=http://www.romzhijia.net/Cooperater/22";#elif index == 4// 手机号归属地 NSString *httpUrl = @"http://apis.baidu.com/apistore/mobilenumber/mobilenumber"; NSString *httpArg = @"phone=15330000000";#elif index == 5// 汉字转拼音 NSString *httpUrl = @"http://apis.baidu.com/xiaogg/changetopinyin/topinyin"; NSString *httpArg = [NSString stringWithFormat:@"str=%@&type=json&traditional=0&accent=0&letter=0&only_chinese=0", [@"哈哈" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];#elif index == 6// MD5解密 NSString *httpUrl = @"http://apis.baidu.com/chazhao/md5decod/md5decod"; NSString *httpArg = @"md5=e807f1fcf82d132f9bb018ca6738a19f";#elif index == 7// 身份证(带生肖和星座) NSString *httpUrl = @"http://apis.baidu.com/chazhao/idcard/idcard"; NSString *httpArg = @"idcard=210905188000111112";#endif AFHTTPSessionManager *httpSessionManager = [AFHTTPSessionManager manager]; [httpSessionManager.requestSerializer setValue:@"4a4332acbba8d97aa1f3940a8b093965" forHTTPHeaderField:@"apikey"]; httpSessionManager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html", @"text/plain", nil]; [httpSessionManager GET:[NSString stringWithFormat:@"%@?%@", httpUrl, httpArg] parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) { } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { NSLog(@"%@", responseObject);#if index == 1 #elif index == 2 NSNumber *num = responseObject[@"errNum"]; if (num.intValue == 0) { NSLog(@"%@", responseObject[@"retData"][@"address"]); }#elif index == 4 NSDictionary *dict = responseObject[@"retData"]; for (NSString *key in dict.allKeys) { NSLog(@"%@\t\t%@", key, dict[key]); }#elif index == 7 NSDictionary *dict = responseObject[@"data"]; for (NSString *key in dict.allKeys) { NSLog(@"%@\t\t%@", key, dict[key]); }#endif } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { NSLog(@"%@", error); }];}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
1 0
- iOS开发之百度免费API使用案例(身份证号获取地址、手机号查归属地、MD5解密等)
- 获取手机号运营商及归属地的免费API
- 利用百度API查询手机号归属地
- 网易有道IP,身份证号, 手机号归属地API查询接口
- 网易有道IP, 手机号, 身份证号归属地查询API接口
- 获取手机号归属地
- 获取手机号归属地
- 调用免费的web service(天气预报,手机号归属地)案例(四)
- java获取手机号归属地
- flex访问webService获取手机号归属地
- JS获取手机号归属地问题
- 利用webservice获取所有手机号归属地
- PHP根据手机号获取归属地
- java根据手机号获取归属地
- 淘宝API——获取IP归属地等信息
- 淘宝API——获取IP归属地等信息
- 免费API-手机号码归属地API接口
- java中根据手机号获取手机号归属地
- React Native十四:原生模块
- 一对多关联查询
- snmp ospf 比较高级的用法,建议详细读取
- 修改eclipse 4 PackageExplorer字体大小及字体类型
- numpy中的ndarray方法和属性
- iOS开发之百度免费API使用案例(身份证号获取地址、手机号查归属地、MD5解密等)
- build your own lisp ch5
- 字符串匹配的KMP算法
- 2.java语言(面向对象语言)
- Android设计模式-模板方法模式
- 深入解读Quartz的原理
- 熟悉Hive 实验1
- leetcode 26. Remove Duplicates from Sorted Array
- HTML5最终会成为iOS和Android替代者吗?