当前位置: 首页>>代码示例>>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;未经允许,请勿转载。