public function MACToken($method, $url, $contentType, $body) { $url = parse_url($url); $data = ''; if (!empty($url['path'])) { $data = $method . ' ' . $url['path']; } if (!empty($url['query'])) { $data .= '?' . $url['query']; } if (!empty($url['host'])) { $data .= "\nHost: " . $url['host']; if (isset($url['port'])) { $data .= ':' . $url['port']; } } if (!empty($contentType)) { $data .= "\nContent-Type: " . $contentType; } $data .= "\n\n"; if (!empty($body)) { $data .= $body; } return 'Qiniu ' . $this->_accessKey . ':' . Utils::sign($this->_secretKey, $data); }
private function _publishDynamicToken($nonce) { $url = parse_url($this->_rtmpPublishBaseUrl()); $data = $url['path']; $separator = empty($url['query']) ? '?' : '&'; if (!empty($url['query'])) { $data .= $separator . $url['query']; } $data .= $separator . 'nonce=' . $nonce; $publishToken = Utils::sign($this->publishKey, $data); return $publishToken; }