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; }
/** * 修改未被查看消息时间 * 本接口用于修改被消费过并且还处于的Inactive的消息到下次可被消费的时间,成功修改消息的VisibilityTimeout后,返回新的ReceiptHandle。 * @param $queueName * @param $receiptHandle * @param $visibilitytimeout * @return array */ public function changeMessageVisibility($queueName, $receiptHandle, $visibilitytimeout) { $request = new ClientRequest("/" . $queueName . "/messages?ReceiptHandle=" . $receiptHandle . "&VisibilityTimeout=" . $visibilitytimeout, ClientRequest::PUT); $request->setContent(""); $response = $this->sendRequest($request); $content = $response->getContent(); return Util::getXmlData($content); }