cherrylu / iotroot
There is no license information available for the latest version (2.0.4) of this package.
php version api for iotroot platform which run by 国家物联网标识管理中心
2.0.4
2024-06-06 06:12 UTC
Requires
- ext-curl: *
- ext-json: *
- ext-openssl: *
- ext-zip: *
- ext-zlib: *
README
先决条件
- PHP >= 5.3
安装
$ composer require cherrylu/iotroot
使用
初始声明
use Cherrylu\iotroot\iotroot; use Cherrylu\iotroot\encrypter; $iotroot = new iotroot('input-your-client-id-here', 'input-your-key-here');
编码申请
$res = $iotroot->ecodeApply(1000);
编码下载-获取已审批编码
/** string 编码申请(ecodeApply)后返回的文件ID */ $fileId = '1717052801031872134201286892242'; $res = $iotroot->queryEcodes($fileId);
编码退回-解绑编码
/** string 编码下载(queryEcodes)返回的数据中获取 */ $ecodes = '201286892242831508353086013003369'; $res = $iotroot->releaseEcodes($ecodes);
获取模板
$res = $iotroot->queryTemplateInfo();
过滤模板字段
// 获取通用模板数据 $templates = $iotroot->queryTemplateInfo(); // 必填的产品字段 $requiredProductItems = $iotroot->productItemFilter($templates['result'][0]); // 所有产品字段 $allProductItems = $iotroot->productItemFilter($templates['result'][0], false); // 必填的非产品字段 $requiredNonProductItems = $iotroot->nonProductItemFilter($templates['result'][0]); // 所有的非产品字段 $allNonProductItems = $iotroot->nonProductItemFilter($templates['result'][0], false);
产品回传-上传产品
/** string 模板ID,从获取模板(queryTemplateInfo)获取 */ $templateId = '54893135bf1f49c18c56e8577d68b5d3'; $productName = '辰砂手串'; $typeNumber = '4208'; $img = base64_encode(file_get_contents('img.jpg')); /** array 产品信息,productItemFilter获取产品信息所需字段 */ $typeList = [ [ "type" => "销售企业信息", "list" => [ [ "name" => "统一社会信用代码", "info" => 'test' ], [ "name" => "法人信息", "info" => 'test' ], [ "name" => "机构地址", "info" => 'test' ], [ "name" => "联系方式", "info" => 'test' ], [ "name" => "机构名称", "info" => 'test' ], [ "name" => "CNAS检测机构", "info" => 'test' ], [ "name" => "CMA检测机构", "info" => 'test' ], ] ], [ "type" => "认证信息", "list" => [ [ "name" => "认证单位", "info" => 'test' ], [ "name" => "认证标准", "info" => 'test' ] ] ], ]; $res = $iotroot->returnProduct($productName, $typeNumber, $templateId, $img, $typeList);
查询产品审核状态
/** string 产品回传(returnProduct)后返回的returnId */ $returnId = '1717052801031872134201286892242'; $res = $iotroot->queryProductStatus($returnId);
批次回传-绑定编码
/** string 产品审核状态(queryProductStatus)返回的数据中获取 */ $productCode = '702e10d0f61b416b862af91e85f7017a'; /** array 编码下载(queryEcodes)返回的数据中获取 */ $ecodes = ['201286892242831508353086013003369']; /** array 从nonProductItemFilter获取所需字段 */ $moduleList = [ [ 'type' => '监督检查信息', 'detailList' => [ ['name' => '检测日期', 'info' => '2023-09-09'], ['name' => '产品图片', 'info' => 'https://img.zbtesting.cn/319/2024/0127/ZSJ32401460511-ssdWUF.jpg'], ['name' => '检测标准', 'info' => 'CMA'], ['name' => '检测员', 'info' => '李四'], ['name' => '追溯码', 'info' => '5609'], ['name' => '授权签字人', 'info' => '张三'], ['name' => '证书编号', 'info' => '10101010101'], ['name' => '检测结论', 'info' => '辰砂手串'], ] ], [ 'type' => '检验检测信息', 'detailList' => [ [ 'name' => '多色性', 'info' => '未检'], [ 'name' => '双折射率', 'info' => '未检'], [ 'name' => '折射率', 'info' => '1.53(点测)'], [ 'name' => '荧光观察', 'info' => '未检'], [ 'name' => '红外光谱', 'info' => '未检'], [ 'name' => '紫外可见光谱', 'info' => '未检'], [ 'name' => '密度', 'info' => '因绳未测'], [ 'name' => '质量', 'info' => '41.16g'], [ 'name' => '外观描述', 'info' => '红色'], [ 'name' => '光性特征', 'info' => '未检'], [ 'name' => '放大检查', 'info' => '粒状结构'], ] ] ]; $iotroot->ecodeBatchReturn($productCode, $ecodes, $moduleList);