當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。