protected function signRequest($path, $method) { // Attempt to authenticate application $publicKey = $this->client->options->get('publicKey'); $privateKey = $this->client->options->get('privateKey'); if ($publicKey !== null && $privateKey !== null) { $date = gmdate(DATE_RFC1123); //Signed requests don't like urlencoded quotes $path = str_replace('%27', '\'', $path); $stringToSign = "{$method}\n" . $date . "\n" . $path . "\n"; $signature = base64_encode(hash_hmac('sha1', $stringToSign, $privateKey, true)); $this->headers->set("Authorization", "BNET" . " " . $publicKey . ":" . $signature); $this->headers->set("Date", $date); } }
protected function signRequest($path, $method) { // Attempt to authenticate application $publicKey = $this->client->options->get('publicKey'); $privateKey = $this->client->options->get('privateKey'); if ($publicKey !== null && $privateKey !== null) { $date = gmdate(DATE_RFC1123); //Signed requests don't like certain some characters, but urldecode changes too many $badCharacters = array('%21', '%26', '%27', '%28', '%29', '%3A', '%40'); $goodCharacters = array('!', '&', '\'', '(', ')', ':', '@'); $path = str_replace($badCharacters, $goodCharacters, $path); $stringToSign = "{$method}\n" . $date . "\n" . $path . "\n"; $signature = base64_encode(hash_hmac('sha1', $stringToSign, $privateKey, true)); $this->headers->set("Authorization", "BNET" . " " . $publicKey . ":" . $signature); $this->headers->set("Date", $date); } }