| 
					
				 | 
			
			
				@@ -17,14 +17,15 @@ use cmf\controller\AdminBaseController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use think\Db; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // 根据腾讯云sdk请求 创建直播拉流 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-use TencentCloud\Cvm\V20170312\CvmClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-use TencentCloud\Cvm\V20170312\Models\DescribeInstancesRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use TencentCloud\Live\V20180801\Models\CreateLivePullStreamTaskRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use TencentCloud\Live\V20180801\Models\DeleteLivePullStreamTaskRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use TencentCloud\Common\Exception\TencentCloudSDKException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use TencentCloud\Common\Credential; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use TencentCloud\Common\Profile\ClientProfile; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use TencentCloud\Common\Profile\HttpProfile; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use TencentCloud\Live\V20180801\LiveClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use think\Exception; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use think\exception\PDOException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 class LiveingController extends AdminbaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     protected function getLiveClass(){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -206,10 +207,6 @@ class LiveingController extends AdminbaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 $data['TaskId'] = $resp->TaskId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 echo json_encode( $data , JSON_UNESCAPED_UNICODE ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                die; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                print_r($resp); die; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             catch(TencentCloudSDKException $e) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -221,24 +218,57 @@ class LiveingController extends AdminbaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public function getPullUrl( $appName, $streamName, $time ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function xiabo() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $domain = $this->pullDomain; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $key    = $this->pullKey; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $txTime = strtoupper( base_convert( strtotime( $time ), 10, 16 ) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $txSecret   = md5( $key . $streamName . $txTime ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $build_data = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "txSecret" => $txSecret, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "txTime"   => $txTime 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $ext_str    = "?" . http_build_query( $build_data ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "rtmp://" . $domain . "/" . $appName . "/" . $streamName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "https://" . $domain . "/" . $appName . "/" . $streamName . ".m3u8", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "https://" . $domain . "/" . $appName . "/" . $streamName . ".flv" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ];; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $uid = $_POST['uid']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $TaskId = $_POST['TaskId']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (empty($uid) || empty($TaskId)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            echo "请输入 TaskId"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } elseif (!is_numeric($uid) || !is_numeric($TaskId)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            echo "TaskId 必须是数字"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。密钥可前往官网控制台 https://console.tencentcloud.com/capi 进行获取 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $cred = new Credential("AKID575vicM9rU6iBiWJNi09HF8xhMxOk4Od", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    "MiDkHwgOFpMpGf2KXcZIo9MYY5qnmhU5"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 实例化一个http选项,可选的,没有特殊需求可以跳过 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $httpProfile = new HttpProfile(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $httpProfile->setEndpoint( "live.tencentcloudapi.com" ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 实例化一个client选项,可选的,没有特殊需求可以跳过 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $clientProfile = new ClientProfile(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $clientProfile->setHttpProfile( $httpProfile ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 实例化要请求产品的client对象,clientProfile是可选的 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $client = new LiveClient( $cred, "ap-bangkok", $clientProfile ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 实例化一个请求对象,每个接口都会对应一个request对象 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $req = new DeleteLivePullStreamTaskRequest(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $params = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    "TaskId"   => $TaskId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    "Operator" => "tom001" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $req->fromJsonString( json_encode( $params ) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 返回的resp是一个DeleteLivePullStreamTaskResponse的实例,与请求对象对应 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $resp = $client->DeleteLivePullStreamTask( $req ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 输出json格式的字符串回包 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $json = $resp->toJsonString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $data['uid'] = $uid; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $data['TaskId'] = '已下播-'.$TaskId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $rs = DB::name('live')->update($data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                return $json; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return json_decode( $json, 1 ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } catch ( TencentCloudSDKException | PDOException | Exception $e ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return [ 'ode' => $e->getCode(), 'msg' => $e->getMessage() ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |