You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.5 KiB
63 lines
1.5 KiB
<?php
|
|
|
|
namespace zixishi\ruifan;
|
|
|
|
|
|
use zixishi\Base;
|
|
|
|
|
|
class Device extends Base
|
|
{
|
|
|
|
/**
|
|
* 生成二维码
|
|
* @param string $device_id 设备ID
|
|
* @param string $token
|
|
* @date 2022-08-02
|
|
*/
|
|
public function createQrcode($device_id, $token)
|
|
{
|
|
$header = [
|
|
'appid:' . $this->config['api_id'],
|
|
'cache-control:no-cache',
|
|
'Content-Type:application/json',
|
|
'datetime:' . time(),
|
|
'token:' . $token,
|
|
];
|
|
|
|
$result = $this->httpPData($this->url . 'v1/Index/openDeviceCode',
|
|
['device_number' => $device_id], $header);
|
|
|
|
// 记录日志
|
|
$uid = defined('UID') ? UID : '';
|
|
platformLog(['device_number' => $device_id], $result, 'zixishi_ruifan_create_qrcode_uid_' . $uid);
|
|
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* 远程开门
|
|
* @param string $device_id 设备ID
|
|
* @param string $token
|
|
* @date 2022-08-02
|
|
*/
|
|
public function openDevice($device_id, $token)
|
|
{
|
|
$header = [
|
|
'appid:' . $this->config['api_id'],
|
|
'cache-control:no-cache',
|
|
'Content-Type:application/json',
|
|
'datetime:' . time(),
|
|
'token:' . $token
|
|
];
|
|
|
|
$result = $this->httpPData($this->url . 'v1/Index/openDevice',
|
|
['device_number' => $device_id], $header);
|
|
|
|
// 记录日志
|
|
$uid = defined('UID') ? UID : '';
|
|
platformLog(['device_number' => $device_id], $result, 'zixishi_ruifan_open_device_uid_' . $uid);
|
|
|
|
return $result;
|
|
}
|
|
} |