當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Request::send方法代碼示例

本文整理匯總了PHP中Httpful\Request::send方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::send方法的具體用法?PHP Request::send怎麽用?PHP Request::send使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Httpful\Request的用法示例。


在下文中一共展示了Request::send方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sendRequest

    /**
     * 執行http發送請求
     *
     * @throws \Httpful\Exception\ConnectionErrorException
     */
    protected function sendRequest()
    {
        !$this->httpful and $this->httpful = Request::init($this->method);
        $payload = '';
        if (in_array($this->httpful->method, ['POST', 'PUT'])) {
            $payload = $this->makePayload();
        }
        $uri = $this->account->getSchemeHost() . $this->requestResource;
        $this->urlParams and $uri .= '?' . http_build_query($this->urlParams) and $this->requestResource .= '?' . http_build_query($this->urlParams);
        $this->httpful->uri($uri);
        $this->httpful->addHeader('Content-Length', strlen($payload));
        $this->httpful->addHeader('Content-MD5', base64_encode(md5($payload)));
        $this->httpful->addHeader('Content-Type', 'text/xml;utf-8');
        $this->httpful->addHeader('Date', date('D, d M Y H:i:s', time()) . ' GMT');
        $this->httpful->addHeader('Host', $this->account->getHost());
        $this->makeSpecificHeaders();
        $this->httpful->body($payload);
        $this->httpful->addHeader('Authorization', $this->makeSignature());
        try {
            return $this->httpful->send();
        } catch (\Exception $e) {
            return new Response(sprintf(<<<EOF
<?xml version="1.0"?>
<Error xmlns="http://mqs.aliyuncs.com/doc/v1">
  <Code>%s</Code>
  <Message>%s</Message>
  <RequestId>0</RequestId>
  <HostId>%s</HostId>
</Error>

EOF
, $e->getCode(), $e->getMessage() . '; FILE: ' . $e->getFile() . '; LINE: ' . $e->getLine(), $this->account->getSchemeHost()), "HTTP/1.1 400 OK\r\nServer: MOCK-SERVER\r\nContent-Type: text/xml;charset=utf-8\r\nx-mqs-request-id: 0", $this->httpful);
        }
    }
開發者ID:baocaixiong,項目名稱:aliyun-mqs-lib,代碼行數:39,代碼來源:BaseRequest.php

示例2: send

 /**
  * Send the request and check for errors.
  *
  * @param \Httpful\Request $request
  *
  * @return array|string
  */
 protected function send(Request $request)
 {
     $response = $request->send();
     $this->hasErrors = $response->hasErrors();
     return json_decode(json_encode($response->body), true);
 }
開發者ID:jakezatecky,項目名稱:work-etc-client-php,代碼行數:13,代碼來源:HttpfulClient.php

示例3: run

 /**
  * run the search
  * 
  * @return \GoogleSearchWrapper\Service\Search
  */
 public function run()
 {
     $this->httpfulResponse = $this->httpfulRequest->send();
     $this->result = new Result($this);
     return $this->result;
 }
開發者ID:wingsuitist,項目名稱:googlesearchwrapper,代碼行數:11,代碼來源:Search.php


注:本文中的Httpful\Request::send方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。