任敬轩 2 лет назад
Родитель
Сommit
c5c21c95f9
2 измененных файлов с 106 добавлено и 4 удалено
  1. 1 2
      Modules/Camera/Services/CameraServices.php
  2. 105 2
      app/Http/Controllers/TestsController.php

+ 1 - 2
Modules/Camera/Services/CameraServices.php

@@ -337,8 +337,7 @@ class CameraServices
                 'camera_name',
                 'cover_picture',
                 'camera_status',
-                'playback',
-                'base64'
+                'playback'
             ]
         )->get()->toArray();
 

+ 105 - 2
app/Http/Controllers/TestsController.php

@@ -28,10 +28,113 @@ class TestsController {
     public function test()
     {
         //宁煤洗选重复摄像头
-        // $this->xixuan_repeat();
+        //$this->xixuan_repeat();
 
         //新接入摄像头接口测试
-        $this->new_joggle();
+        //$this->new_joggle();
+
+        //乐橙token
+        $this->token();
+
+        //乐橙直播列表
+        $this->list();
+    }
+
+    //直播列表
+    public function list(){
+//        At_0000bd7f06fa796842778d92b50d4d2d
+        $url = 'https://openapi.lechange.cn/openapi/liveList';
+        //当前的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',
+            'queryRange'=>"1-10"
+        ];
+        //组装调用接口的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);
+        //调用后返回输出
+        echo 'result:<br>'.nl2br($utf8 ).'<br>';
+    }
+
+    public function token(){
+//        At_0000bd7f06fa796842778d92b50d4d2d
+        $url = 'https://openapi.lechange.cn:443/openapi/accessToken';
+        //当前的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 = [];
+        //组装调用接口的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);
+        //调用后返回输出
+        echo 'result:<br>'.nl2br($utf8 ).'<br>';
+    }
+
+    function curl_post($data,$url)
+    {
+        $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);
+        curl_setopt($ch, CURLOPT_POST, 1);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
+        $result = curl_exec ($ch);
+        curl_close($ch);
+        if ($result == NULL) {
+            return 0;
+        }
+        return $result;
     }
 
     //新接入摄像头接口测试