萤石云添加设备提示高风险需要确权的处理方法

439 阅读1分钟

 最近萤石云升级了,长时间离线的设备 ,不能直接添加了,需要确权之后才可以添加,好麻烦了,目前没有公开的接口可以 做这个操作。今天问官方要了一份接口文件
接口必须使用GET请求
确权需要2步,第一步是确定离线,第二步是确定在线

一、确定设备离线
1、accessToken    token值
2、deviceSerial  序列号

https://open.ys7.com/api/userdevice/v3/devices/realtimestatus


二、确定设备在线
1、accessToken    token值
2、deviceSerial  序列号

https://open.ys7.com/api/userdevice/v3/devices/permission


以下为完整请求代码(GET)

$url = "https://open.ys7.com/api/userdevice/v3/devices/permission?accessToken={$AccessToken}&deviceSerial={$xlh}";
$html = file_get_contents($url);
$msg = json_decode($html, true)['meta']['message'];
if(empty($msg)){
        $msg = json_decode($html, true)['meta']['code'];
}
header("Content-type:text/html;charset=utf-8");
echo $msg


以下为添加设备到平台代码(POST)

$url="https://open.ys7.com/api/lapp/device/add";
$data1 = ["accessToken" => $AccessToken,"deviceSerial"=>$xlh,"validateCode"=>$yzm];
$content1 = posturl($url, $data1);
$msg=$content1['msg'];
header("Content-type:text/html;charset=utf-8");
echo $msg