_accessKey = $accessKey; $this->_secretKey = $secretKey; } 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); } }