function RTMPPublishURL($domain, $hub, $streamKey, $expireAfterSeconds, $accessKey, $secretKey) { $expire = time() + $expireAfterSeconds; $path = sprintf("/%s/%s?e=%d", $hub, $streamKey, $expire); $token = $accessKey . ":" . Utils::sign($secretKey, $path); return sprintf("rtmp://%s%s&token=%s", $domain, $path, $token); }
public function __construct($transport, $hub, $key) { $this->_transport = $transport; $this->_hub = $hub; $this->_key = $key; $cfg = Config::getInstance(); $protocal = $cfg->USE_HTTPS === true ? "https" : "http"; $this->_baseUrl = sprintf("%s://%s/%s/hubs/%s/streams/%s", $protocal, $cfg->API_HOST, $cfg->API_VERSION, $this->_hub, Utils::base64UrlEncode($this->_key)); }
private function _setHeaders($method, $url, $body = NULL) { if ($method != HttpRequest::GET) { $cType = 'application/json'; } else { $cType = NULL; } $macToken = $this->_mac->MACToken($method, $url, $cType, $body); $ua = Utils::getUserAgent(Config::SDK_USER_AGENT, Config::SDK_VERSION); return array('Content-Type' => $cType, 'User-Agent' => $ua, 'Authorization' => $macToken); }
public function testUrlSafe() { $a = '你好'; $b = Utils::base64UrlEncode($a); $this->assertEquals($a, Utils::base64UrlDecode($b)); }