IOT设备信息查询API用于查询当前在AlipayIOT平台中已注册机具机具信息和绑定信息,查询条件有两种:
1. 设备sn + 供应商id
2. 设备sn + 物料id
全部业务场景
快速接入文档参考《蚂蚁平台快速接入》。
alipay-sdk-JAVA-3.4.28.ALL 及更新版本
alipay-sdk-NET-3.2.110.ALL及更新版本
alipay-sdk-PHP-3.3.132.ALL及更新版本
| 参数 | 类型 | 是否必填 | 最大长度 | 示例值 | 描述 |
|---|---|---|---|---|---|
| device_sn | String | 是 | 60 | 863420180404008888 | 真实设备sn |
| supplier_sn | String | 特殊可选 | 20 | 201803023499238 | 供应商id,supplier_sn/item_id参数二选一必填,如果在supplier_sn item_id都输入的情况下,优先匹配supplier_sn |
| item_id | String | 特殊可选 | 20 | 407 | 物料id,supplier_sn/item_id二选一必填,如果在supplier_sn item_id都输入的情况下,优先匹配supplier_sn |
| 名称 | 具体类型 | 是否必填 | 最大长度 | 示例值 | 描述 |
|---|---|---|---|---|---|
| status | String | 是 | 20 | ACTIVED | 机具状态,可用值: “UNREGISTER” – 未注册 “ACTIVED” – 已激活 “UNACTIVED” – 未激活 |
| biz_tid | String | 是 | 60 | 01010020015XNJgH9AX333333m73k2HRTyNACsri6nASVFRedpogo3lc | 设备id,支付宝内生产的设备唯一id |
| biz_type | String | 是 | 20 | 团餐机具 | 设备使用业务场景: 团餐机具 快消机具 未来校园 K12 长尾机具 智能售卖 公交机具 客运机具 餐饮机具 政务机具 医疗机具 高速机具 酒店机具 |
| isv_pid | String | 否 | 20 | 2088123456789 | 机具所属ISV的ID |
| bind_status | String | 是 | 10 | BIND | 机具绑定状态,可用值: “BIND”–已绑定 “UNBIND”–未绑定 |
| merchant_pid | String | 否 | 20 | 2088987654321 | 机具绑定的商户id |
| shop_id | String | 否 | 40 | 2018053000077000000053888888 | 机具绑定的使用门店id |
| ext_info | String | 否 | 1000 | {“contractID”:“11111”} | 扩展信息 source_type-激活方式: [SDK激活/云端激活/服务端自激活] |
| item_id | String | 是 | 20 | 408 | 物料id |
| supplier_sn | String | 是 | 20 | 201812345678 | 机具供应商id |
@Test
public void deviceReigster() throws AlipayApiException {
//实例化客户端
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", "app_id", "your private_key", "json", "GBK", "alipay_public_key", "RSA2");
AlipayCommerceIotMdeviceprodDeviceQueryRequest request = new AlipayCommerceIotMdeviceprodDeviceQueryRequest();
request.setBizContent("{" +
"\"device_sn\":\"863420180404008888\"," +
"\"supplier_sn\":\"201803023499238\"," +
"\"item_id\":\"407\"" +
" }");
AlipayCommerceIotMdeviceprodDeviceQueryResponse response = alipayClient.execute(request);
if (response.isSuccess()) {
System.out.println("调用成功");
} else {
System.out.println("调用失败");
}
}
IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", "app_id", "merchant_private_key", "json", "1.0", "RSA2", "alipay_public_key", "GBK", false);
AlipayCommerceIotMdeviceprodDeviceQueryRequest request= new AlipayCommerceIotMdeviceprodDeviceQueryRequest() ;
request.BizContent="{" +
"\"device_sn\":\"863420180404008888\"," +
"\"supplier_sn\":\"201803023499238\"," +
"\"item_id\":\"407\"" +
" }";
AlipayCommerceIotMdeviceprodDeviceQueryResponse response=client.execute(request);
Console.WriteLine(response.Body);
$aop = new AopClient ();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = 'your app_id';
$aop->rsaPrivateKey = '请填写开发者私钥去头去尾去回车,一行字符串';
$aop->alipayrsaPublicKey='请填写支付宝公钥,一行字符串';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='GBK';
$aop->format='json';
$request = new AlipayCommerceIotMdeviceprodDeviceQueryRequest ();
$request->setBizContent("{" .
"\"device_sn\":\"863420180404008888\"," .
"\"supplier_sn\":\"201803023499238\"," .
"\"item_id\":\"407\"" .
" }");
$result = $aop->execute ( $request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
if(!empty($resultCode)&&$resultCode == 10000){
echo "成功";
} else {
echo "失败";
}
<!--http请求原文,url必须经过转义后进行POST请求-->
https://openapi.alipay.com/gateway.do?timestamp=2013-01-01 08:08:08&method=alipay.commerce.iot.mdeviceprod.device.query&app_id=14482&sign_type=RSA2&sign=ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE&version=1.0&charset=GBK&biz_content= {"device_sn":"863420180404008888","supplier_sn":"201803023499238","item_id":"407" }
{
"alipay_commerce_iot_mdeviceprod_device_query_response":{
"code":"10000",
"msg":"Success",
"status":"ACTIVED",
"biz_tid":"01010020015XNJgH9AX333333m73k2HRTyNACsri6nASVFRedpogo3lc",
"biz_type":"团餐机具",
"isv_pid":"2088123456789",
"bind_status":"BIND",
"merchant_pid":"2088987654321",
"shop_id":"2018053000077000000053888888",
"ext_info":"{\"contractID\":\"11111\"}",
"item_id":"408",
"supplier_sn":"201812345678"
},
"sign":"ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
}