push_host . '/app/ceshi'; $key = $this->push_auth_key; $exp = time() + 3600; $authurl = $this->authKey($uri, $key, $exp); return $this->data(['push_url'=>$authurl]); } public function getPullUrl() { $uri = $this->pull_host . '/app/ceshi'; $key = $this->pull_auth_key; $exp = time() + 3600; $authurl = $this->authKey($uri, $key, $exp); return $this->data(['push_url'=>$authurl]); } private function authKey($uri, $key, $exp) { preg_match("/^(rtmp:\/\/)?([^\/?]+)?(\/[^?]*)?(\\?.*)?$/", $uri, $matches); $scheme = $matches[1] ?? ''; $host = $matches[2] ?? ''; $path = $matches[3] ?? ''; if (empty($scheme)) { $scheme ="rtmp://"; } if (empty($path)) { $path ="/"; } $uid = $rand = "0"; $string = sprintf("%s-%u-%s-%s-%s", $path, $exp, $rand, $uid, $key); $hashvalue = md5($string); $auth_key = sprintf("%u-%s-%s-%s", $exp, $rand, $uid, $hashvalue); return sprintf("%s%s%s?auth_key=%s", $scheme, $host, $path, $auth_key); } public function forbidLiveStream() { $config = new Config([ "accessKeyId" => $this->access_key_id, "accessKeySecret" => $this->access_key_secret ]); $config->endpoint = "live.aliyuncs.com"; $client = new OpenApiClient($config); $params = new Params([ "action" => "ForbidLiveStream", "version" => "2016-11-01", "protocol" => "HTTP", "method" => "POST", "authType" => "AK", "style" => "RPC", "pathname" => "/", "reqBodyType" => "json", "bodyType" => "json" ]); $queries = []; $queries["DomainName"] = "push-live.lihaink.cn"; $queries["AppName"] = "app"; $queries["StreamName"] = "ceshi"; $queries["LiveStreamType"] = "publisher"; $runtime = new RuntimeOptions([]); $request = new OpenApiRequest([ "query" => OpenApiUtilClient::query($queries) ]); $res = $client->callApi($params, $request, $runtime); halt($res); } public function resumeLiveStream() { $config = new Config([ "accessKeyId" => $this->access_key_id, "accessKeySecret" => $this->access_key_secret ]); $config->endpoint = "live.aliyuncs.com"; $client = new OpenApiClient($config); $params = new Params([ "action" => "ResumeLiveStream", "version" => "2016-11-01", "protocol" => "HTTP", "method" => "POST", "authType" => "AK", "style" => "RPC", "pathname" => "/", "reqBodyType" => "json", "bodyType" => "json" ]); $queries = []; $queries["DomainName"] = "push-live.lihaink.cn"; $queries["LiveStreamType"] = "publisher"; $queries["AppName"] = "app"; $queries["StreamName"] = "ceshi"; $runtime = new RuntimeOptions([]); $request = new OpenApiRequest([ "query" => OpenApiUtilClient::query($queries) ]); $res = $client->callApi($params, $request, $runtime); halt($res); } public function test() { $config = new Config([ "accessKeyId" => $this->access_key_id, "accessKeySecret" => $this->access_key_secret ]); $config->endpoint = "live.aliyuncs.com"; $client = new OpenApiClient($config); $params = new Params([ "action" => "DescribeLiveStreamsOnlineList", "version" => "2016-11-01", "protocol" => "HTTP", "method" => "POST", "authType" => "AK", "style" => "RPC", "pathname" => "/", "reqBodyType" => "json", "bodyType" => "json" ]); $queries = []; $queries["DomainName"] = "live.lihaink.cn"; $runtime = new RuntimeOptions([]); $request = new OpenApiRequest([ "query" => OpenApiUtilClient::query($queries) ]); $res = $client->callApi($params, $request, $runtime); halt($res); } }