push_host . '/app/ceshi'; $key = $this->push_auth_key; $exp = time() + 3600; $authuri = $this->authKey($uri, $key, $exp); return $this->data([$authuri]); } public function getPullUrl() { $uri = $this->pull_host . '/app/ceshi'; $key = $this->pull_auth_key; $exp = time() + 3600; $authuri = $this->authKey($uri, $key, $exp); return $this->data([$authuri]); } 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); } }