|
|
|
@ -8,13 +8,24 @@ use think\Request; |
|
|
|
class Smartlock extends Base |
|
|
|
{ |
|
|
|
|
|
|
|
public function deviceStatus() |
|
|
|
/** |
|
|
|
* 获取设备状态信息 |
|
|
|
* @param Request $request |
|
|
|
* @return false|string |
|
|
|
*/ |
|
|
|
public function deviceStatus(Request $request) |
|
|
|
{ |
|
|
|
try { |
|
|
|
$request = Request::instance(); |
|
|
|
if (!$request->isPost()) throw new \Exception("请求失败,仅允许POST请求方式"); |
|
|
|
|
|
|
|
$curlData = YingShiSdk::DeviceStatus(); |
|
|
|
$accessToken = $request->header('AccessToken'); |
|
|
|
$json = $request->getContent(); |
|
|
|
$param = json_decode($json, true); |
|
|
|
|
|
|
|
if (empty($accessToken)) throw new \Exception('AccessToken参数,不能为空'); |
|
|
|
if (empty($param['deviceSerial'])) throw new \Exception('deviceSerial参数,不能为空'); |
|
|
|
|
|
|
|
$curlData = YingShiSdk::DeviceStatus($accessToken,$param['deviceSerial']); |
|
|
|
|
|
|
|
if (!is_array($curlData)) throw new \Exception("cURL Error #:" . $curlData); |
|
|
|
|
|
|
|
@ -24,13 +35,24 @@ class Smartlock extends Base |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function deviceInfo() |
|
|
|
/** |
|
|
|
* 获取单个设备信息 |
|
|
|
* @param Request $request |
|
|
|
* @return false|string |
|
|
|
*/ |
|
|
|
public function deviceInfo(Request $request) |
|
|
|
{ |
|
|
|
try { |
|
|
|
$request = Request::instance(); |
|
|
|
if (!$request->isPost()) throw new \Exception("请求失败,仅允许POST请求方式"); |
|
|
|
|
|
|
|
$curlData = YingShiSdk::DeviceInfo(); |
|
|
|
$accessToken = $request->header('AccessToken'); |
|
|
|
$json = $request->getContent(); |
|
|
|
$param = json_decode($json, true); |
|
|
|
|
|
|
|
if (empty($accessToken)) throw new \Exception('AccessToken参数,不能为空'); |
|
|
|
if (empty($param['deviceSerial'])) throw new \Exception('deviceSerial参数,不能为空'); |
|
|
|
|
|
|
|
$curlData = YingShiSdk::DeviceInfo($accessToken,$param['deviceSerial']); |
|
|
|
|
|
|
|
if (!is_array($curlData)) throw new \Exception("cURL Error #:" . $curlData); |
|
|
|
|
|
|
|
|