任敬轩 2 лет назад
Родитель
Сommit
1c2775a8f1

+ 2 - 0
Modules/Camera/Http/Controllers/Api/HaiKangController.php

@@ -86,6 +86,8 @@ class HaiKangController extends BaseController
                 }
             }
             $result['data']['list'] = array_values($list);
+        }else{
+            $result['data']['list'] = [];
         }
 
         if ($type == CameraEnum::REQUEST_TYPE_API) {

+ 50 - 4
app/Http/Controllers/TestsController.php

@@ -34,10 +34,13 @@ class TestsController {
         //$this->new_joggle();
 
         //乐橙token
-        $this->token();
+//        $this->token();
 
         //乐橙直播列表
         $this->list();
+
+        //根据序列号获取直播地址和直播状态
+//        $this->address();
     }
 
     //直播列表
@@ -59,7 +62,7 @@ class TestsController {
         //业务参数
         $params = [
             'token'=>'At_0000bd7f06fa796842778d92b50d4d2d',
-            'queryRange'=>"1-10"
+            'queryRange'=>"1-99"
         ];
         //组装调用接口的body体内容
         $data = json_encode([
@@ -78,7 +81,51 @@ class TestsController {
         $ret = $this->curl_post($data, $url);
         $utf8 = iconv('utf-8', 'UTF-8', $ret);
         //调用后返回输出
-        echo 'result:<br>'.nl2br($utf8 ).'<br>';
+//        dd(nl2br($utf8));
+        $aa = json_decode(nl2br($utf8), true);
+        dd($aa['result']['data']);
+    }
+
+    //根据序列号获取直播地址和直播状态
+    public function address(){
+        //        At_0000bd7f06fa796842778d92b50d4d2d
+        $url = 'https://openapi.lechange.cn/openapi/getLiveStreamInfo';
+        //当前的UTC时间戳
+        $time= strtotime(date('Y-m-d H:i:s',time()));
+        //随机字符串
+        $nonce = md5(time());
+        //授权信息之appid
+        $appId='lc753b03152e3b4f1e';
+        //授权信息之appSecret
+        $appSecret='cc9b1224acd24571a5daf18e8c7f94';
+        //拼接计算“签名原始串”
+        $signStr="time:$time,nonce:$nonce,appSecret:$appSecret";
+        //计算摘要 sign
+        $sign=md5($signStr);
+        //业务参数
+        $params = [
+            'token'=>'At_0000bd7f06fa796842778d92b50d4d2d',
+            'deviceId'=>'6J0C716PAZ6CF87',
+            'channelId'=>22
+        ];
+        //组装调用接口的body体内容
+        $data = json_encode([
+            'system'=>
+                [
+                    'ver'=>'1.0',
+                    'sign'=>$sign,
+                    'appId'=>$appId,
+                    'time'=>$time,
+                    'nonce'=>$nonce
+                ],
+            'params'=>empty($params)? new \stdClass():$params,
+            'id'=>'88'
+        ]);
+        //http调用
+        $ret = $this->curl_post($data, $url);
+        $utf8 = iconv('utf-8', 'UTF-8', $ret);
+        //调用后返回输出
+        dd(nl2br($utf8 ));
     }
 
     public function token(){
@@ -122,7 +169,6 @@ class TestsController {
     {
         $ch = curl_init();
         $res= curl_setopt ($ch, CURLOPT_URL,$url);
-        var_dump($res);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt ($ch, CURLOPT_HEADER, 0);