+(NSDictionary *)getWANIP
{
//通过淘宝的服务来定位WAN的IP,否则获取路由IP没什么用
NSURL *ipURL = [NSURL URLWithString:@"http://ip.taobao.com/service/getIpInfo.php?ip=myip"];
NSData *data = [NSData dataWithContentsOfURL:ipURL];
NSDictionary *ipDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSDictionary * dic = [ipDic objectForKey:@"data"];
NSString *ipStr = nil;
if (ipDic && [ipDic[@"code"] integerValue] == 0) { //获取成功
ipStr = ipDic[@"data"][@"country"];
}
ios开发技术,提交审核讨论群 加qq群:695614778 一起讨论