如何免费用java c#实现手机在网状态查询
创始人
2024-12-27 23:06:47
0

       今天分享手机在网状态查询接口,该接口适用的场景非常广泛!首先我们先讲下什么是手机在网状态?简单来说,就是你得手机号是否还在正常使用中,是否能够及时接收和回复信息,是否能够随时接听和拨打电话。如果你得手机号处于停机、欠费或者注销的状态,那么你的手机号就处于非在网状态。

1.接口名称:手机在网状态查询

2.接口用途:输入手机号码查询手机号在网状态,返回有正常使用、停机、在网但不可用、不在网(销号/未启用/异常)、预销户等十几种状态,可查询实时状态,准确率99.99%

3.免费试用:手机运营商在网状态查询-API专区-云市场

以下为具体的Java实现代码过程:

	public static void main(String[] args) { 	    String host = "https://kzmstatev1.market.alicloudapi.com"; 	    String path = "/api-mall/api/mobile_status/check"; 	    String method = "POST"; 	    String appcode = "你自己的AppCode"; 	    Map headers = new HashMap(); 	    //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105 	    headers.put("Authorization", "APPCODE " + appcode); 	    //根据API的要求,定义相对应的Content-Type 	    headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 	    Map querys = new HashMap(); 	    Map bodys = new HashMap(); 	    bodys.put("mobile", "mobile");   	    try { 	    	/** 	    	* 重要提示如下: 	    	* HttpUtils请从 	    	* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java 	    	* 下载 	    	* 	    	* 相应的依赖请参照 	    	* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml 	    	*/ 	    	HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys); 	    	System.out.println(response.toString()); 	    	//获取response的body 	    	//System.out.println(EntityUtils.toString(response.getEntity())); 	    } catch (Exception e) { 	    	e.printStackTrace(); 	    } 	} 

以下为具体的C#实现代码过程:

//using System.IO; //using System.Text; //using System.Net; //using System.Net.Security; //using System.Security.Cryptography.X509Certificates;          private const String host = "https://kzmstatev1.market.alicloudapi.com";         private const String path = "/api-mall/api/mobile_status/check";         private const String method = "POST";         private const String appcode = "你自己的AppCode";          static void Main(string[] args)         {             String querys = "";             String bodys = "mobile=mobile";             String url = host + path;             HttpWebRequest httpRequest = null;             HttpWebResponse httpResponse = null;              if (0 < querys.Length)             {                 url = url + "?" + querys;             }              if (host.Contains("https://"))             {                 ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);                 httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));             }             else             {                 httpRequest = (HttpWebRequest)WebRequest.Create(url);             }             httpRequest.Method = method;             httpRequest.Headers.Add("Authorization", "APPCODE " + appcode);             //根据API的要求,定义相对应的Content-Type             httpRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";             if (0 < bodys.Length)             {                 byte[] data = Encoding.UTF8.GetBytes(bodys);                 using (Stream stream = httpRequest.GetRequestStream())                 {                     stream.Write(data, 0, data.Length);                 }             }             try             {                 httpResponse = (HttpWebResponse)httpRequest.GetResponse();             }             catch (WebException ex)             {                 httpResponse = (HttpWebResponse)ex.Response;             }              Console.WriteLine(httpResponse.StatusCode);             Console.WriteLine(httpResponse.Method);             Console.WriteLine(httpResponse.Headers);             Stream st = httpResponse.GetResponseStream();             StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));             Console.WriteLine(reader.ReadToEnd());             Console.WriteLine("\n");          }          public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)         {             return true;         } 

以下为具体的python实现代码过程:

import urllib, urllib2, sys import ssl   host = 'https://kzmstatev1.market.alicloudapi.com' path = '/api-mall/api/mobile_status/check' method = 'POST' appcode = '你自己的AppCode' querys = '' bodys = {} url = host + path  bodys['mobile'] = '''mobile''' post_data = urllib.urlencode(bodys) request = urllib2.Request(url, post_data) request.add_header('Authorization', 'APPCODE ' + appcode) //根据API的要求,定义相对应的Content-Type request.add_header('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8') ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE response = urllib2.urlopen(request, context=ctx) content = response.read() if (content):     print(content) 

返回的数据结构如下:

 "msg": "成功",     "success": true,     "code": 200,     "data": {         "orderNo": "202406282055560705659",         "result": "1",         "province": "北京",         "city": "北京",         "channel": "移动",         "resultMsg": "正常"

相关内容

热门资讯

第2分钟操作!圣游科技辅助器,... 第2分钟操作!圣游科技辅助器,随意玩房卡辅助器透视(辅助)本来有挂平台(哔哩哔哩)1、随意玩房卡辅助...
五分钟手筋!好友赣南新版本挂,... 您好,好友赣南新版本挂这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩...
五分钟手筋!贰柒拾智能辅助柒,... 五分钟手筋!贰柒拾智能辅助柒,新广西老友辅助(辅助)其实存在有插件(哔哩哔哩)进入游戏-大厅左侧-新...
7分钟举措!丫丫衡阳字牌3辅助... 7分钟举措!丫丫衡阳字牌3辅助,樱花之盛辅助器下载(辅助)一贯是真的平台(哔哩哔哩)1、7分钟举措!...
第3分钟教程书!掌电竞技辅助器... 第3分钟教程书!掌电竞技辅助器,悟空大厅辅助器(辅助)一贯是有辅助器(哔哩哔哩)1)掌电竞技辅助器辅...
第2分钟法子!哈糖大菠萝可以开... 第2分钟法子!哈糖大菠萝可以开挂吗,悟空大厅辅助器下载(辅助)确实真的是有软件(哔哩哔哩)1、进入到...
第五分钟机巧!闲逸软件可以控制... 第五分钟机巧!闲逸软件可以控制的吗,新众亿挂机(辅助)都是是有神器(哔哩哔哩)第五分钟机巧!闲逸软件...
1分钟绝活!悠闲卡五星辅助,来... 1分钟绝活!悠闲卡五星辅助,来来拼十辅助(辅助)本来存在有下载(哔哩哔哩)1、悠闲卡五星辅助免费脚本...
第4分钟技法!边锋干瞪眼小程序... 第4分钟技法!边锋干瞪眼小程序辅助,道游互娱辅助免费版(辅助)本来真的有辅助器(哔哩哔哩)1、玩家可...
脚本曝光!hhpoker俱乐部... 脚本曝光!hhpoker俱乐部是干嘛的,hhpoker辅助软件(透视)切实真的有神器(哔哩哔哩)1、...