public function handle(HTTPApiClient $apiClient, ClientRequest $clientRequest)
 {
     if (!$apiClient instanceof Client) {
         return $clientRequest;
     }
     $content_md5 = base64_encode(md5($clientRequest->getContent()));
     $gmt_date = Util::getGMTDate();
     $clientRequest->setHeader('x-mqs-version', static::X_MQS_VERSION);
     $canonicalizedMQSHeaders = array();
     foreach ($clientRequest->getHeaders() as $key => $value) {
         if (preg_match('/^x\\-mqs\\-/', $key)) {
             $canonicalizedMQSHeaders[$key] = $value;
         }
     }
     ksort($canonicalizedMQSHeaders, SORT_STRING);
     $sign = Util::getSignature($clientRequest->getVerb(), $content_md5, static::CONTENT_TYPE, $gmt_date, $canonicalizedMQSHeaders, $clientRequest->getUrl(), $apiClient->getAccessKey(), $apiClient->getAccessSecret());
     $clientRequest->setHeader('Host', $apiClient->getQueueOwnerId() . "." . $apiClient->getMqsUrl());
     $clientRequest->setHeader('Date', $gmt_date);
     $clientRequest->setHeader('Content-Type', static::CONTENT_TYPE);
     $clientRequest->setHeader('Content-MD5', $content_md5);
     $clientRequest->setHeader('Authorization', $sign);
     $clientRequest->setUrl('http://' . $apiClient->getQueueOwnerId() . "." . $apiClient->getMqsUrl() . $clientRequest->getUrl());
     return $clientRequest;
 }
示例#2
0
 /**
  * 获取多个消息队列列表
  * @param string $prefix
  * @param string $number
  * @param string $marker
  * @return array
  */
 public function listQueue($prefix = '', $number = '', $marker = '')
 {
     $request = new ClientRequest("/", ClientRequest::GET);
     $request->setHeader('x-mqs-prefix', $prefix);
     $request->setHeader('x-mqs-ret-number', $number);
     $request->setHeader('x-mqs-marker', $marker);
     $request->setContent("");
     $response = $this->sendRequest($request);
     $content = $response->getContent();
     return Util::getXmlData($content);
 }