1 changed files with 62 additions and 0 deletions
@ -0,0 +1,62 @@ |
|||
<?php |
|||
|
|||
namespace app\api\controller\video; |
|||
|
|||
use app\api\controller\Controller; |
|||
|
|||
class Video extends Controller |
|||
{ |
|||
|
|||
public function getVideo() |
|||
{ |
|||
$config = config('api_config'); |
|||
$url = $config['host_url'] . "/api/resource/v1/cameras"; |
|||
$token = getAccessToken(); |
|||
|
|||
# 获取视频资源 |
|||
try { |
|||
|
|||
$dataArr = [ |
|||
'pageNo' => 1, |
|||
'pageSize' => 10, |
|||
]; |
|||
$json_data = json_encode($dataArr); |
|||
$result = postToken($url,$json_data,false,[],$token); |
|||
|
|||
$res_data = json_decode($result,true); |
|||
if ($res_data['code'] != 0) throw new \Exception('请求失败'); |
|||
$list = (array)$res_data['data']['list']; |
|||
|
|||
$urlArr = []; |
|||
foreach ($list as $row) { |
|||
|
|||
# 获取监控点视频链接 |
|||
$cameraIndexCode = $row['cameraIndexCode']; |
|||
$url2 = $config['host_url'] . "/api/video/v2/cameras/previewURLs"; |
|||
$dataArr2 = [ |
|||
'cameraIndexCode' => $cameraIndexCode, |
|||
'streamType' => 0, |
|||
'transmode' => $row['transType'], |
|||
'expand' => 'transcode=0', |
|||
'streamform' => 'ps' |
|||
]; |
|||
$json_data2 = json_encode($dataArr2); |
|||
$result2 = postToken($url2,$json_data2,false,[],$token); |
|||
$res_data2 = json_decode($result2,true); |
|||
if ($res_data2['code'] != 0) throw new \Exception('请求失败'); |
|||
$list2 = (array)$res_data2['data']; |
|||
|
|||
foreach ($list2 as $row2) { |
|||
$urlArr[] = $row2; |
|||
} |
|||
} |
|||
|
|||
} catch (\Exception $e) { |
|||
return $this->renderError($e->getMessage()); |
|||
} |
|||
|
|||
dump($urlArr); dump($list);die; |
|||
|
|||
return $this->renderSuccess(compact('urlArr')); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue