java电信移动联通api

编程入门 行业动态 更新时间:2024-10-13 16:16:22

java<a href=https://www.elefans.com/category/jswz/34/1768917.html style=电信移动联通api"/>

java电信移动联通api

require_once 'curl.func.php';

$appkey = 'your_appkey_here';//你的appkey

$shouji = '13456755448';

$url = "=$appkey&shouji=$shouji";

$result = curlOpen($url, ['ssl'=>true]);

$jsonarr = json_decode($result, true);

//exit(var_dump($jsonarr));

if($jsonarr['status'] != 0)

{

echo $jsonarr['msg'];

exit();

}

$result = $jsonarr['result'];

echo $result['province'].' '.$result['city'].' '.$result['company'].' '.$result['cardtype'].'

';

#!/usr/bin/python

# encoding:utf-8

import urllib2, json, urllib

# 1、区号查询

data = {}

data["appkey"] = "your_appkey_here"

data["shouji"] = "13456755448"

url_values = urllib.urlencode(data)

url = "" + "?" + url_values

request = urllib2.Request(url)

result = urllib2.urlopen(request)

jsonarr = json.loads(result.read())

if jsonarr["status"] != u"0":

print jsonarr["msg"]

exit()

result = jsonarr["result"]

print result["province"],result["city"],result["company"],result["cardtype"]

package api.jisuapi.shouji;

import api.util.HttpUtil;

import net.sf.json.JSONObject;

public class Query {

public static final String APPKEY = "your_appkey_here";// 你的appkey

public static final String URL = "";

public static final String shouji = "13456755448";

public static void Get() {

String result = null;

String url = URL + "?appkey=" + APPKEY + "&shouji=" + shouji;

try {

result = HttpUtil.sendGet(url, "utf-8");

JSONObject json = JSONObject.fromObject(result);

if (json.getInt("status") != 0) {

System.out.println(json.getString("msg"));

} else {

JSONObject resultarr = json.optJSONObject("result");

String province = resultarr.getString("province");

String city = resultarr.getString("city");

String company = resultarr.getString("company");

String cardtype = resultarr.getString("cardtype");

System.out.println(province + " " + city + " " + company + " " + cardtype);

}

} catch (Exception e) {

e.printStackTrace();

}

}

}

更多推荐

java电信移动联通api

本文发布于:2024-03-10 20:49:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1729002.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:电信   java   api

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!