diff --git a/application/api/controller/YingShiDevice.php b/application/api/controller/YingShiDevice.php new file mode 100644 index 0000000..aa4c68b --- /dev/null +++ b/application/api/controller/YingShiDevice.php @@ -0,0 +1,39 @@ +jsonSuccess('操作成功',$curlData); + } catch (\Exception $e) { + return $this->jsonError($e->getMessage()); + } + } + + public function deviceInfo() + { + try { + + $curlData = YingShiSdk::DeviceInfo(); + + if (!is_array($curlData)) throw new \Exception("cURL Error #:" . $curlData); + + return $this->jsonSuccess('操作成功',$curlData); + + } catch (\Exception $e) { + return $this->jsonError($e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/application/common/YingShiSdk/YingShiSdk.php b/application/common/YingShiSdk/YingShiSdk.php new file mode 100644 index 0000000..eaa764c --- /dev/null +++ b/application/common/YingShiSdk/YingShiSdk.php @@ -0,0 +1,103 @@ + "{$url}?accessToken={$accessToken}&deviceSerial={$deviceSerial}", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_HTTPHEADER => [ + "Content-Type: application/x-www-form-urlencoded" + ], + ]); + + curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false); + curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,false); + curl_setopt($curl,CURLOPT_SSLVERSION,0); + + $response = curl_exec($curl); + $err = curl_error($curl); + + curl_close($curl); + + return [ + 'err' => $err, + 'response' => $response + ]; + } +} \ No newline at end of file