集团客户可批量查询集团内处于欠费停机状态的物联卡,一次最多查询20张卡。
请求地址:https://api.iot.10086.cn/v2/arrearageuserinfo
请求方式:GET/POST
参数 | 是否必须 | 默认值 | 含义 |
---|---|---|---|
appid |
是 | 无 | 应用编码,第三方应用唯一标识。由物联卡集团客户向中国移动提出API接入申请,中国移动物联网全网管理员在运营管理平台上分配并反馈给集团客户(反馈方式:邮箱),appid样例:100001 |
transid |
是 | 无 | 事务编码,由物联卡集团客户按照相应规则自主生成(不可超过48位)。生成规则:appid+YYYYMMDDHHMISS+8位数字序列(此序列由集团客户自主生成,比如从00000001开始递增等等),transid样例:1000012014101615303080000001 |
ebid |
是 | 无 | 能力编码,同appid一起由中国移动反馈给集团客户,ebid样例:2300000000000001 |
token |
是 | 无 | 令牌,appid+password+transid(password同appid、ebid一起由中国移动反馈给集团客户)并使用64位SHA-256算法进行加密,token样例: 4962ad69adcbf490c9f749fff734b 5706a874ebab1120aaa23c9d288290534ca |
参数 | 是否必须 | 默认值 | 含义 |
---|---|---|---|
pageSize |
是 | 无 | 必须为大于等于1且小于等于20的整数 |
pageNum |
是 | 无 | 必须传入大于0的整数 |
应答公共信息:
参数 | 是否必须 | 默认值 | 含义 |
---|---|---|---|
status |
是 | 无 | 返回码: 0-正确,非0-失败 |
message |
是 | 无 | 错误信息。错误码对应的错误描述,参考错误码列表 |
result |
是 | 无 | 返回结果集(status为“0”时,result包含正确的结果数据;status为“非0”时, result可能为空,也可能包含其他提示数据) |
应答数据信息:
参数 | 是否必须 | 默认值 | 含义 |
---|---|---|---|
arrearageUserInfo |
是 | 无 | 欠费停机用户查询结果 |
total |
是 | 无 | 总计异常用户数 |
userInfos |
是 | 无 | 当前请求页面用户数量 |
msisdn |
是 | 无 | 用户卡号 |
status |
是 | 无 | 异常状态,欠费停机用户状态包括: 02-停机且停机原因为欠费停机 |
currentDate |
是 | 无 | 当前查询日期,日期格式为YYYYMMDD |
statusDate |
是 | 无 | 状态变更日期,日期格式为YYYYMMDD |
https://api.iot.10086.cn/v2/arrearageuserinfo?appid=xxx&ebid=xxx&transid=xxx&token=xxx&pageSize=xxx&pageNum=xxx
package com.iot;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
*
* @author IOT JAVA请求API服务平台接口demo
*
*/
public class CMIOT_API2022 {
// 请求URL的IP和端口,需要按实际环境修改
public static final String ipAndPort = "http://api.iot.10086.cn";
// 请求的版本号
public static final String version = "/v2";
// 请求具体的接口名称
public static final String apiName = "/arrearageuserinfo";
/**
* 获取请求接口的返回信息
*
* @param url
* 请求接口时需要传入的URL
*/
public static String sendRequest(String url) {
InputStream inputStream = null;
BufferedReader bufferedReader = null;
HttpURLConnection httpURLConnection = null;
try {
URL requestURL = new URL(url);
// 获取连接
httpURLConnection = (HttpURLConnection) requestURL.openConnection();
httpURLConnection.setConnectTimeout(10000); //建立连接的超时时间,毫秒
httpURLConnection.setReadTimeout(25000); //获得返回的超时时间,毫秒
httpURLConnection.setRequestMethod("GET");
// 通过输入流获取请求的内容
inputStream = httpURLConnection.getInputStream();
bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
String temp = null;
StringBuffer stringBuffer = new StringBuffer();
// 循环读取返回的结果
while ((temp = bufferedReader.readLine()) != null) {
stringBuffer.append(temp);
}
return stringBuffer.toString();
} catch (Exception e) {
e.printStackTrace();
}finally {
//断开连接
if (httpURLConnection!=null) {
httpURLConnection.disconnect();
}
// 关闭流
if(bufferedReader!=null){
try {
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(inputStream!=null){
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return null;
}
/**
* 构造请求地址URL
* @param paramMap 请求参数
* @return URL
*/
private static String buildUrl(Map<String, String> paramMap){
String url = null;
StringBuffer urlString = new StringBuffer();
urlString.append(ipAndPort).append(version).append(apiName);
if (!paramMap.isEmpty()) {
// 参数列表不为空,地址尾部增加'?'
urlString.append('?');
// 拼接参数
Set<Map.Entry<String, String>> entrySet = paramMap.entrySet();
for (Map.Entry<String, String> entry : entrySet) {
try {
urlString.append(entry.getKey()).append('=').append(URLEncoder.encode(entry.getValue(), "UTF-8")).append('&');
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
// 去掉最后一个字符“&”
url = urlString.substring(0, urlString.length() - 1);
}
return url;
}
public static void main(String[] args) throws IOException {
// 封装请求接口的参数,需要按实际环境修改
HashMap<String, String> map = new HashMap<>();
map.put("appid", "A0B40O5");
map.put("ebid", "0001000000432");
map.put("transid", "A0B40O5201601102201");
map.put("token", "2a9c4f3741b4864e6c003e2caa9c826b5c9fa388d27e82b1b6894aeddd8ed121");
map.put("pageSize", "20");
map.put("pageNum", "2");
// 通过参数构造请求URL和参数
String url = buildUrl(map);
// 获取接口返回信息
String result = sendRequest(url);
System.out.println(result);
}
}
<?php
//设置页面显示编码UTF-8
header("Content-Type: text/html;charset=utf-8");
// 请求URL的IP和端口,需要按实际环境修改
$ipAndPort = "http://api.iot.10086.cn";
// 请求的版本号
$version = "/v2";
// 请求具体的接口名称
$apiName = "/arrearageuserinfo";
/**
* 请求API的方法
* @param GET方式请求地址 $URL
* @return 返回请求的数据
*/
function requestAPI($URL) {
//创建一个新的CURL资源赋值给 $curl
$curl=curl_init();
//设置URL
curl_setopt($curl, CURLOPT_URL, $URL);
//执行请求
$result=curl_exec($curl);
// ===用于区分空输入和布尔值false
if ($result===false) {
echo "error ! plese check you requset url...";
}
//释放资源
curl_close($curl);
return $result;
}
/**
* 构造URL方法
* @param unknown $params
*/
function buildURL($params){
$strURL=null;
foreach ($params as $key=>$value){
$strURL=$strURL.$key."=".urlencode($value)."&";
}
//去除最后一个"&";
$strURL=substr($strURL, 0, -1);
global $ipAndPort;
global $version;
global $apiName;
//拼接URL
$strURL=$ipAndPort.$version.$apiName.'?'.$strURL;
return $strURL;
}
//定义参数,需要按实际环境修改
$params=array(
'token'=>'2a9c4f3741b4864e6c003e2caa9c826b5c9fa388d27e82b1b6894aeddd8ed121',
'appid'=>'A0B40O5',
'transid'=>'A0B40O5201601102201',
'ebid'=>'0001000000432',
'pageSize'=>'20',
'pageNum'=>'2'
);
$requestURL=buildURL($params);
requestAPI($requestURL);
?>
# -*- coding: utf-8 -*-
'''
@author IOT Python2.79请求API服务平台接口
#CMIOT_API2022-欠费停机用户批量查询
'''
import urllib, urllib2
def send_request_get(ipAndPort,version,api_name,**kwargs):
'''
说明:组装url并调用接口
:param ipAndPort: ip及端口信息
:param version: 版本号
:param api_name: api名称
:param kwargs: 参数
:return: 调用API返回的信息
'''
base_url = ipAndPort + version + api_name
params = urllib.urlencode(kwargs)
url = '?'.join([base_url,params])
print u'调用URL:'+url
try:
response = urllib2.urlopen(url)
except urllib2.URLError,e:
raise ValueError(e)
response_message = response.read()
return response_message
class API_Demo_Request:
#CMIOT_API2022-欠费停机用户批量查询
def test_13_CMIOT_API2022(self):
#1.接口的参数及数据准备
appid = 'A0B40O5' #应用编码--需要按实际环境修改
ebid = '0001000000432' #能力编码--需要按实际环境修改
pageSize='20' #每页显示数量--需要按实际需要修改
pageNum='0' #查询第几页--需要按实际需要修改
transid = "A0B40O5201601102201" #transid--需要按实际环境修改
token = "2a9c4f3741b4864e6c003e2caa9c826b5c9fa388d27e82b1b6894aeddd8ed121" #token--需要按实际环境修改
api_name = "arrearageuserinfo" #请求具体的接口名称
ipAndPort = "http://api.iot.10086.cn" #请求URL的IP和端口--需要按实际环境修改
version = "/v2/" #请求的版本号--需要按实际环境修改
#2.接口调用"
#接口调用格式https://api.iot.10086.cn/v2/arrearageuserinfo?appid=xxx&ebid=xxx&transid=xxx&token=xxx&pageSize=xxx&pageNum=xxx
response_message = send_request_get(ipAndPort,version,api_name,appid=appid,ebid =ebid,transid=transid,token=token,pageSize=pageSize,pageNum=pageNum)
#3.接口调用返回的信息
print response_message
if __name__=='__main__':
API_Demo_Request().test_13_CMIOT_API2022()
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace HttpDemo
{
class Program
{
static void Main(string[] args)
{
//CMIOT_API2022-欠费停机用户批量查询
string domain = "http://api.iot.10086.cn/v2/";//需要按照实际环境修改
string enabler = "arrearageuserinfo";
//以下业务参数需要根据实际情况修改
string appid = "A3CI163"; //应用编号
string transid = "A3CI1632017051214010379823456";//事务编码
string ebid = "0001000000027";//能力编号
string token = "4b524a2958e823bd9245f733dc9a38a14784baef5151edf0f532296611c07564";
string pageSize = "20"; //每页数量
string pageNum = "1"; //页码
string paramters = "?appid=" + appid + "&transid=" + transid + "&ebid=" + ebid + "&token=" + token + "&pageSize=" + pageSize + "&pageNum=" + pageNum;
string uri = domain + enabler + paramters;
string response = RequestSync(uri, "post"); //同步get请求把post改为get即可
Debug.WriteLine(response);
Console.ReadLine();
}
//同步get 或 post
public static string RequestSync(string uri, string method)
{
WebRequest request = WebRequest.Create(uri);
//get 或者 post
request.Method = method;
//读取返回消息
string res = string.Empty;
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
res = reader.ReadToEnd();
reader.Close();
}
catch (Exception ex)
{
res = ex.ToString();
}
return res;
}
}
}
{
"status":"0",
"message":"正确",
"result":[
{
"arrearageUserInfo":{
"total":"2",
"userInfos":[
{
"msisdn":"xxx",
"status":"02",
"currentDate":"20151228",
"statusDate":"20130828"
},
{
"msisdn":"xxx",
"status":"02",
"currentDate":"20151228",
"statusDate":"20130828"
}
]
}
}
]
}