当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::send方法代码示例

本文整理汇总了PHP中GuzzleHttp\Client::send方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::send方法的具体用法?PHP Client::send怎么用?PHP Client::send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GuzzleHttp\Client的用法示例。


在下文中一共展示了Client::send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doRequest

 /**
  * @return array
  */
 public function doRequest() : array
 {
     $this->generateRequestOptions();
     $this->authenticator->authenticate($this);
     $request = $this->httpClient->createRequest($this->method, $this->getUrl(), $this->requestOptions);
     return $this->httpClient->send($request)->json();
 }
开发者ID:silwerclaw,项目名称:jirapi,代码行数:10,代码来源:Request.php

示例2: getResponse

 /**
  * Get the result of the http request.
  *
  * @return Response
  */
 protected function getResponse()
 {
     if ($this->response === null) {
         $this->response = $this->client->send($this->request);
     }
     return $this->response;
 }
开发者ID:SmartCrowd,项目名称:Embed,代码行数:12,代码来源:Guzzle5.php

示例3: subscribe

 /**
  * Method to handle the Subscribe Request to the Hub
  */
 public function subscribe()
 {
     // Start empty $hubUrl variable
     $hubUrl = '';
     // Check if the Hub URL finishes with a / or not to be able to create the correct subscribe URL
     if (preg_match("/\\/\$/", $this->current_options['hub_url'])) {
         $hubUrl = $this->current_options['hub_url'] . 'subscribe';
     } else {
         $hubUrl = $this->current_options['hub_url'] . '/subscribe';
     }
     // Json Data needed to send to the Hub for Subscription
     $subscribeJson = json_encode(array("callbackUrl" => esc_url($this->callbackUrl), "topicId" => esc_url($this->current_options['topic_url'])), JSON_UNESCAPED_SLASHES);
     $subscribeRequest = $this->guzzleClient->createRequest('POST', $hubUrl);
     $subscribeRequest->setHeader('Content-Type', 'application/json');
     $subscribeRequest->setBody(Stream::factory($subscribeJson));
     $subscribeResponse = $this->guzzleClient->send($subscribeRequest);
     // Check if Response is 200, 202 or 204 and add a log message otherwise log error message
     if (in_array($subscribeResponse->getStatusCode(), array(200, 202, 204))) {
         HubLogger::log('Your Subscription request is being processed. Check back later to see if you are fully Subscribed', $subscribeResponse->getStatusCode());
         return true;
     } else {
         HubLogger::error('Error issuing Subscribe request to the Hub. Please make sure all your details are correct', $subscribeResponse->getStatusCode());
         return false;
     }
 }
开发者ID:dannyoz,项目名称:tls,代码行数:28,代码来源:HubSubscriber.php

示例4: send

 /**
  * @param \DonePM\ConsoleClient\Http\Commands\Command $command
  *
  * @return mixed|\Psr\Http\Message\ResponseInterface
  */
 public function send(Command $command)
 {
     if ($command instanceof NeedsToken) {
         $command->token($this->token);
     }
     return $this->client->send($command->request());
 }
开发者ID:donepm,项目名称:cli-client,代码行数:12,代码来源:Client.php

示例5: request

 /**
  * @param string $method
  * @param string $uri
  * @param array  $options
  *
  * @return ResponseInterface
  */
 public function request($method, $uri, array $options = [])
 {
     $this->lazyLoadGuzzle();
     $this->lastRequest = $this->guzzle->createRequest($method, $uri, $options);
     $response = $this->guzzle->send($this->lastRequest);
     return $response;
 }
开发者ID:prgtw,项目名称:basecrm-php-api,代码行数:14,代码来源:GuzzleClient.php

示例6: get

 /**
  * @param string $path
  * @param array $queryParams
  *
  * @return \StdClass
  *
  * @throws RequestException
  */
 private function get($path, array $queryParams = array())
 {
     $url = self::BASE_URI . $path;
     $request = $this->createHttpRequest('GET', $url, $queryParams);
     $response = $this->httpClient->send($request);
     return $this->parseResponse($response);
 }
开发者ID:gnoesiboe,项目名称:FHPostcodeAPIClient,代码行数:15,代码来源:Client.php

示例7: request

 /**
  * @param  Request  $request
  * @return Response
  */
 public function request(Request $request)
 {
     $guzzleRequest = $this->prepareRequest($request);
     /** @var GuzzleResponse $guzzleResponse */
     $guzzleResponse = $this->client->send($guzzleRequest);
     return new Response($guzzleResponse->getProtocolVersion(), (int) $guzzleResponse->getStatusCode(), $guzzleResponse->getReasonPhrase(), HeaderConverter::convertComplexAssociativeToFlatAssociative($guzzleResponse->getHeaders()), (string) $guzzleResponse->getBody());
 }
开发者ID:saxulum,项目名称:saxulum-http-client-adapter-guzzle,代码行数:11,代码来源:HttpClient.php

示例8: send

 /**
  * Send the request and return the response.
  *
  * @param  Request $request
  * @param  string  $url
  * @return Response
  */
 public function send(Request $request, $url)
 {
     $guzzleRequest = $this->convertRequest($request);
     $guzzleRequest->setUrl($url);
     $guzzleResponse = $this->client->send($guzzleRequest);
     return $this->convertResponse($guzzleResponse);
 }
开发者ID:Creare,项目名称:CreareProxy,代码行数:14,代码来源:GuzzleAdapter.php

示例9: testItIsNotStupid

 /**
  * @param Request $request
  *
  * @dataProvider nonCachableRequestProvider
  */
 public function testItIsNotStupid(Request $request)
 {
     $this->client->send($request);
     // Will not be cached
     $response = $this->client->send($request);
     // Will not come from cache
     $this->assertEquals(CacheMiddleware::HEADER_CACHE_MISS, $response->getHeaderLine(CacheMiddleware::HEADER_CACHE_INFO));
 }
开发者ID:kevinrob,项目名称:guzzle-cache-middleware,代码行数:13,代码来源:GreedyCacheTest.php

示例10: sendGuzzleRequest

 protected function sendGuzzleRequest($http_verb = 'GET', $url, $data = null)
 {
     if (date(time()) >= Session::get('oauth_token_expiry')) {
         $this->refreshAccessToken();
     }
     $request = $this->client->createRequest($http_verb, $url, ['json' => $data, 'headers' => ['Authorization' => 'Bearer ' . Session::get('access_token')]]);
     return $this->client->send($request)->json();
 }
开发者ID:adrielpdeguzman,项目名称:chainofmemories_gui,代码行数:8,代码来源:BaseController.php

示例11: sendRequest

 /**
  * Send a request and convert any BadResponseExceptions to a RequestException
  * 
  * @param \GuzzleHttp\Psr7\Request $request
  * @return \Psr\Http\Message\ResponseInterface
  * @throws Exception\RequestException
  */
 protected function sendRequest(Request $request)
 {
     try {
         return $this->http_client->send($request);
     } catch (ClientException $e) {
         throw new Exception\RequestException($e);
     }
 }
开发者ID:unl,项目名称:rev_api,代码行数:15,代码来源:Rev.php

示例12: execute

 public function execute($method, $uri, $data)
 {
     $request = $this->guzzleClient->createRequest($method, $uri, $data);
     /** @var ResponseInterface $response */
     /** @noinspection PhpVoidFunctionResultUsedInspection */
     $response = $this->guzzleClient->send($request);
     return new Response($response);
 }
开发者ID:credibility,项目名称:dandb,代码行数:8,代码来源:Requester.php

示例13: broadcast

 /**
  * Broadcast the given event.
  *
  * @param  array $channels
  * @param  string $event
  * @param  array $payload
  * @return void
  */
 public function broadcast(array $channels, $event, array $payload = array())
 {
     foreach ($channels as $channel) {
         $payload = ['text' => array_merge(['eventtype' => $event], $payload)];
         $request = $this->client->createRequest('POST', '/pub?id=' . $channel, ['json' => $payload]);
         $response = $this->client->send($request);
     }
 }
开发者ID:cmosguy,项目名称:laravel-http-pushstream-broadcaster,代码行数:16,代码来源:PushStreamBroadcaster.php

示例14: send

 /**
  * @inheritDoc
  *
  * @param RequestInterface $request request
  *
  * @return ResponseInterface
  */
 public function send(RequestInterface $request)
 {
     $options = array('curl' => []);
     foreach ($this->curlOptions as $option => $value) {
         $options['curl'][constant('CURLOPT_' . strtoupper($option))] = $value;
     }
     $options['verify'] = __DIR__ . '/../../Resources/cert/cacert.pem';
     return $this->client->send($request, $options);
 }
开发者ID:alebon,项目名称:graviton,代码行数:16,代码来源:GuzzleAdapter.php

示例15: send

 /**
  * @param \Psr\Http\Message\RequestInterface $request
  * @param array $options
  *
  * @throws \Spryker\Zed\Payolution\Business\Exception\ApiHttpRequestException
  *
  * @return string
  */
 protected function send($request, array $options = [])
 {
     try {
         $response = $this->client->send($request, $options);
     } catch (RequestException $requestException) {
         throw new ApiHttpRequestException($requestException->getMessage());
     }
     return $response->getBody();
 }
开发者ID:spryker,项目名称:Payolution,代码行数:17,代码来源:Guzzle.php


注:本文中的GuzzleHttp\Client::send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。