用户信息类

CMIOT_API2003-码号信息查询

根据ICCID、IMSI、MSISDN任意1个码号查询剩余2个码号信息的能力。


API请求参数说明

请求地址:https://api.iot.10086.cn/v2/cardinfo

请求方式:GET/POST


公共参数

参数 是否必须 默认值 含义

appid

应用编码,第三方应用唯一标识。由物联卡集团客户向中国移动提出API接入申请,中国移动物联网全网管理员在运营管理平台上分配并反馈给集团客户(反馈方式:邮箱),appid样例:100001

transid

事务编码,由物联卡集团客户按照相应规则自主生成(不可超过48位)。生成规则:appid+YYYYMMDDHHMISS+8位数字序列(此序列由集团客户自主生成,比如从00000001开始递增等等),transid样例:1000012014101615303080000001

ebid

能力编码,同appid一起由中国移动反馈给集团客户,ebid样例:2300000000000001

token

令牌,appid+password+transid(password、ebid一起由中国移动反馈给集团客户)并使用64位SHA-256算法进行加密,token样例: 4962ad69adcbf490c9f749fff734b 5706a874ebab1120aaa23c9d288290534ca


业务参数

参数 是否必须 默认值 含义

card_info

所查询用户的msisdn、imsi或iccid

type

  • 0—msisdn
  • 1—imsi
  • 2—iccid

返回参数说明

应答公共信息:

参数 是否必须 默认值 含义

status

返回码:

0-正确,非0-失败

message

错误信息。错误码对应的错误描述,参考错误码列表

result

返回结果集(status为“0”时,result包含正确的结果数据;status为“非0”时, result可能为空,也可能包含其他提示数据)

应答数据信息:

参数 是否必须 默认值 含义

IMSI

国际移动用户识别码

MSISDN

物联网专网卡号

ICCID

集成电路卡识别码,IC卡的唯一识别号码


API请求URL示例

https://api.iot.10086.cn/v2/cardinfo?appid=xxx&transid=xxx&ebid=xxx&token=xxx&card_info=xxx&type=xxx


API请求示例代码

  • Java
  • PHP
  • Python
  • C#
复制代码

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_API2003 {

	// 请求URL的IP和端口,需要按实际环境修改
	public static final String ipAndPort = "http://api.iot.10086.cn";
	// 请求的版本号
	public static final String version = "/v2";
	// 请求具体的接口名称
	public static final String apiName = "/cardinfo";

	/**
	 * 获取请求接口的返回信息
	 *
	 * @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", "0001000000423");
		map.put("transid", "A0B40O52016090714165048673958");
		map.put("token", "1cfec83fcb528180371b0cabc5f7a48b1afb50c90e584ed692e2527f4b19a27b");
		map.put("card_info", "14765003512");
		map.put("type", "0");

		// 通过参数构造请求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 = "/cardinfo";

            /**
             * 请求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'=>'1cfec83fcb528180371b0cabc5f7a48b1afb50c90e584ed692e2527f4b19a27b',
                'appid'=>'A0B40O5',
                'transid'=>'A0B40O52016090714165048673958',
                'ebid'=>'0001000000423',
                'card_info'=>'14765003512',
                'type'=>'0'

            );

            $requestURL=buildURL($params);
            requestAPI($requestURL);

?>
                    

# -*- coding: utf-8 -*-
'''
@author IOT Python2.79请求API服务平台接口

#CMIOT_API2003-码号信息查询
'''

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_API2003-码号信息查询
    def test_11_CMIOT_API2003(self):
        #1.接口的参数及数据准备
        appid = "A0B40O5"                #应用编码--需要按实际环境修改
        ebid = "0001000000423"                  #能力编码--需要按实际环境修改
        transid = "A0B40O52016090714165048673958" #transid--需要按实际环境修改
        token = "1cfec83fcb528180371b0cabc5f7a48b1afb50c90e584ed692e2527f4b19a27b" #token--需要按实际环境修改
        msisdn = "14765003512"               #MISDN 号码--需要按实际环境修改
        api_name = "cardinfo"        #请求具体的接口名称
        type = 0                    #卡号类型--需要按实际环境修改
        ipAndPort = "http://api.iot.10086.cn" #请求URL的IP和端口--需要按实际环境修改
        version = "/v2/"   #请求的版本号--需要按实际环境修改

        #2.接口调用"
        #接口调用格式https://api.iot.10086.cn/v2/cardinfo?appid=xxx&ebid=xxx&transid=xxx&token=xxx&card_info=xxx&type=xxx
        response_message = send_request_get(ipAndPort,version,api_name,appid=appid,ebid =ebid,transid=transid,token=token,card_info=msisdn,type=type)

        #3.接口调用返回的信息
        print response_message

if __name__=='__main__':
    API_Demo_Request().test_11_CMIOT_API2003()
                    

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_API2003-码号信息查询
            string domain = "http://api.iot.10086.cn/v2/";//需要按照实际环境修改
            string enabler = "cardinfo";

            //以下业务参数需要根据实际情况修改
            string appid = "A3CI163";   //应用编号
            string transid = "A3CI1632017051214010379823456";//事务编码
            string ebid = "0001000000027";//能力编号
            string token = "4b524a2958e823bd9245f733dc9a38a14784baef5151edf0f532296611c07564";
            string card_info = "";    //所查询用户的msisdn、imsi或iccid
            string type = "0";    //0—msisdn 1—imsi  2—iccid

            string paramters = "?appid=" + appid + "&transid=" + transid + "&ebid=" + ebid + "&token=" + token + "&card_info=" + card_info + "&type=" + type;
            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;
        }
    }
}
                    

API响应示例

                {
    "status":"0",
    "message":"正确",
    "result":[
        {
            "IMSI":"460040260908676",
            "MSISDN":"1064826090209",
            "ICCID":"898602B2221430000006"
        }
    ]
}
            

错误码

  • 查看错误码

API工具

  • token生成工具
  • SDK工具下载