示例#1
0
 /**
  * Signs the API request.
  *
  * @param string $url
  * @param string $verb
  * @param string $content
  * @return array
  * @since 0.2.0
  */
 private function sign($url, $verb, $content = null)
 {
     $current_date = date('c');
     $request_info = $verb . $url . $current_date;
     if ('POST' == $verb) {
         $content_type = 'multipart/form-data; boundary=' . $this->mime_builder->boundary();
         $request_info .= $content_type . $content;
     }
     $secret_key = base64_decode($this->credentials->secret());
     $hash = hash_hmac('sha256', $request_info, $secret_key, true);
     $signature = base64_encode($hash);
     return 'HHMAC; key=' . $this->credentials->key() . '; signature=' . $signature . '; date=' . $current_date;
 }