套餐类查询

CMIOT_API2037-物联卡资费套餐查询

集团客户可以根据物联卡码号信息查询该卡的套餐信息。


API请求参数说明

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

请求方式: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


业务参数

参数 是否必须 默认值 含义 校验规则

msisdn

所查询的物联卡号码,最长13位数字,举例:14765004176,msisdn、iccid、imsi三者必须有且只有一项

msisdn、iccid、imsi必须有且只有一项

iccid

集成电路卡识别码,IC卡的唯一识别号码,共有20位字符组成,举例:898600D6991330004146,msisdn、iccid、imsi三者必须有且只有一项

imsi

国际移动用户识别码,其总长度不超过15位,使用0~9的数字,举例:460079650004176,msisdn、iccid、imsi三者必须有且只有一项


返回参数说明

应答公共信息:

参数 是否必须 默认值 含义

status

返回码:

0-正确,非0-失败

message

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

result

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

应答数据信息:

参数 是否必须 默认值 含义

msisdn

物联网专网卡号

iccid

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

imsi

国际移动用户识别码

prodinfos

套餐信息

prodid

套餐资费编号

prodname

SIM卡套餐名称

prodinstefftime

该套餐的生效时间

prodinstexptime

该套餐的失效时间


API请求URL示例

https://api.iot.10086.cn/v2/querycardprodinfo?appid=xxx&transid=xxx&ebid=xxx&token=xxx&msisdn=xxx –以msisdn进行查询

https://api.iot.10086.cn/v2/querycardprodinfo?appid=xxx&transid=xxx&ebid=xxx&token=xxx&iccid=xxx –以iccid进行查询

https://api.iot.10086.cn/v2/querycardprodinfo?appid=xxx&transid=xxx&ebid=xxx&token=xxx&imsi=xxx –以imsi进行查询


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

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

/**
 * 获取请求接口的返回信息
 *
 * @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", "A0B40O9");
		map.put("ebid", "0001000000578");
		map.put("transid", "2016071314451512365445");
		map.put("token", "93209c5a9290f278d754823075b9708837157cabb318894882aa44afdfd810b0");
		map.put("msisdn", "1064828139459");

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

            /**
             * 请求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'=>'93209c5a9290f278d754823075b9708837157cabb318894882aa44afdfd810b0',
                'appid'=>'A0B40O9',
                'transid'=>'2016071314451512365445',
                'ebid'=>'0001000000578',
                'msisdn'=>'1064828139459'
            );

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

?>
                    

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

CMIOT_API2037	物联卡资费套餐查询
'''

import urllib, urllib2,datetime


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_API2037-物联卡资费套餐查询
    def test_15_CMIOT_API2037(self):
    #1.接口的参数及数据准备
    appid = 'A0B40O9'               #应用编码--需要按实际环境修改
    ebid = '0001000000578'                 #能力编码--需要按实际环境修改
    transid = "2016071314451512365445" #transid--需要按实际环境修改
    token = "93209c5a9290f278d754823075b9708837157cabb318894882aa44afdfd810b0" #token--需要按实际环境修改
    msisdn = "1064828139459"               #MISDN 号码--需要按实际环境修改
    api_name = "querycardprodinfo"        #请求具体的接口名称
    ipAndPort = "http://api.iot.10086.cn" #请求URL的IP和端口--需要按实际环境修改
    version = "/v2/"   #请求的版本号--需要按实际环境修改

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

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

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

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace HttpDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            //CMIOT_API2037-物联卡资费套餐查询
            string domain = "http://api.iot.10086.cn/v2/";//需要按照实际环境修改
            string enabler = "querycardprodinfo";

            //以下业务参数需要根据实际情况修改
            string appid = "0NZ";   //应用编号
            string transid = "0NZ2017051611163080000001";//事务编码
            string ebid = "0001000000559";//能力编号
            string token = "4b524a2958e823bd9245f733dc9a38a14784baef5151edf0f532296611c07564";
            string msisdn = "1064828139459";  //msisdn、imsi、iccid 三个参数有且仅有一个即可

            string paramters = "?appid=" + appid + "&transid=" + transid + "&ebid=" + ebid + "&token=" + token + "&msisdn=" + msisdn;     //msisdn 可改为imsi或iccid
            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响应示例

                {
"message": "正确",
"result": [
    {
        "iccid": "898602B2221340000878",
        "imsi": "460040260900788",
        "msisdn": "1064828139459",
        "prodinfos": [
            {
                "prodid": "I00010100061",
                "prodinstefftime":"2016-08-01 00:00:00",
                "prodinstexptime":"2099-12-31 23:59:59",
                "prodname": "GPRS中小流量新3元套餐"
            },
            {
                "prodid": "I00010100031",
                "prodinstefftime":"2016-08-01 00:00:00",
                "prodinstexptime":"2099-12-31 23:59:59",
                "prodname": "沉默测试套餐"
            }
        ]
    }
],
"status": "0"
}
            

错误码

  • 查看错误码

API工具

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