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


PHP Http\ClientInterface類代碼示例

本文整理匯總了PHP中Guzzle\Http\ClientInterface的典型用法代碼示例。如果您正苦於以下問題:PHP ClientInterface類的具體用法?PHP ClientInterface怎麽用?PHP ClientInterface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: addPsrLoggerToClient

 /**
  * @param ClientInterface $client
  * @param LoggerInterface $logger
  * @param null|string $formatter
  * @return LogPlugin
  */
 public static function addPsrLoggerToClient(ClientInterface $client, LoggerInterface $logger, $formatter = self::SIMPLE_FORMAT)
 {
     $formatter = is_null($formatter) ? self::SIMPLE_FORMAT : $formatter;
     $adapter = new PsrLogAdapter($logger);
     $plugin = new LogPlugin($adapter, $formatter);
     $client->addSubscriber($plugin);
     return $plugin;
 }
開發者ID:subscribo,項目名稱:omnipay-subscribo-shared,代碼行數:14,代碼來源:GuzzleClientHelper.php

示例2: factory

 /**
  * Factory method which allows for easy service creation
  *
  * @param  ClientInterface $client
  * @return self
  */
 public static function factory(ClientInterface $client)
 {
     $identity = new self();
     if (($client instanceof Base || $client instanceof OpenStack) && $client->hasLogger()) {
         $identity->setLogger($client->getLogger());
     }
     $identity->setClient($client);
     $identity->setEndpoint(clone $client->getAuthUrl());
     return $identity;
 }
開發者ID:skinnard,項目名稱:FTL-2,代碼行數:16,代碼來源:Service.php

示例3: factory

 /**
  * Factory method which allows for easy service creation
  *
  * @param  ClientInterface $client
  * @return self
  */
 public static function factory(\Guzzle\Http\ClientInterface $client)
 {
     $tempAuth = new self();
     if (($client instanceof \OpenCloud\Common\Base || $client instanceof \OpenCloud\OpenStack) && $client->hasLogger()) {
         $tempAuth->setLogger($client->getLogger());
     }
     $tempAuth->setClient($client);
     $tempAuth->setEndpoint(clone $client->getAuthUrl());
     return $tempAuth;
 }
開發者ID:fia-net,項目名稱:openstack-tempauth,代碼行數:16,代碼來源:TempAuth.php

示例4: load

 /**
  * {@inheritdoc}
  */
 public function load(ClassMetadata $metadata, ParserInterface $parser)
 {
     // Create a request with basic Auth
     $request = $this->client->get('repos/' . $this->owner . '/' . $this->repository . '/contents');
     try {
         // Send the request and get the response.
         $response = $request->send();
     } catch (ClientErrorResponseException $e) {
         $this->handleBadResponseExceptions($e);
     }
     $files = $response->json();
     $batch = array();
     foreach ($files as $file) {
         $batch[] = $this->client->get('repos/' . $this->owner . '/' . $this->repository . '/contents/' . $file['path']);
     }
     try {
         $responses = $this->client->send($batch);
     } catch (MultiTransferException $e) {
         $this->handleBadResponseExceptions($e->getFirst());
     }
     $content = array();
     foreach ($responses as $response) {
         $file = $response->json();
         $decodedContent = base64_decode($file['content']);
         $content[] = $parser->parse($metadata, $file['name'], $decodedContent);
     }
     return $content;
 }
開發者ID:fabricius,項目名稱:fabricius,代碼行數:31,代碼來源:GithubLoader.php

示例5: loadWsdl

 /**
  * Load remote WSDL to local cache.
  *
  * @param string $url
  * @return string
  */
 public function loadWsdl($url)
 {
     $response = $this->guzzleClient->get($url)->send();
     $cacheFilePath = $this->getCachedWsdlPath($url);
     $this->fs->dumpFile($cacheFilePath, $response->getBody(true));
     return $cacheFilePath;
 }
開發者ID:antrampa,項目名稱:crm,代碼行數:13,代碼來源:WsdlManager.php

示例6: post

 /**
  * {@inheritdoc}
  */
 public function post($url, array $headers = array(), $content = '')
 {
     $headers['content-type'] = 'application/json';
     $request = $this->client->post($url, $headers, $content);
     $this->response = $request->send();
     return $this->response->getBody(true);
 }
開發者ID:BAY-A,項目名稱:Gravity-Forms-DigitalOcean,代碼行數:10,代碼來源:GuzzleAdapter.php

示例7: load

 /**
  * {@inheritdoc}
  */
 public function load(ClassMetadata $metadata, ParserInterface $parser)
 {
     // Create a request with basic Auth
     $request = $this->client->get('metadata/dropbox/' . $this->path);
     try {
         // Send the request and get the response.
         $response = $request->send();
     } catch (ClientErrorResponseException $e) {
         $this->handleBadResponseExceptions($e);
     }
     $responseBody = $response->json();
     $batch = array();
     foreach ($responseBody['contents'] as $file) {
         $batch[] = $this->client->get('https://api-content.dropbox.com/1/files/dropbox' . $file['path']);
     }
     try {
         $responses = $this->client->send($batch);
     } catch (MultiTransferException $e) {
         $this->handleBadResponseExceptions($e->getFirst());
     }
     $content = array();
     foreach ($responses as $response) {
         $url = parse_url($response->getEffectiveUrl());
         $filename = basename($url['path']);
         $receivedContent = $response->getBody(true);
         $content[] = $parser->parse($metadata, $filename, $receivedContent);
     }
     return $content;
 }
開發者ID:fabricius,項目名稱:fabricius,代碼行數:32,代碼來源:DropboxLoader.php

示例8: handleRequest

 /**
  * Sends the request to given URL and returns JSON response.
  * 
  * @param string
  * @return void
  */
 public function handleRequest($url)
 {
     $request = $this->client->get($url);
     $json = ['success' => TRUE, 'error' => NULL, 'body' => NULL];
     $this->enableCrossDomainRequests();
     try {
         $result = $request->send(TRUE);
     } catch (CurlException $e) {
         $json['success'] = FALSE;
         $json['error'] = sprintf("Unable to handle request: CURL failed with message '%s'.", $e->getError());
         switch ($e->getErrorNo()) {
             case CURLE_COULDNT_RESOLVE_HOST:
                 http_response_code(404);
                 break;
             default:
                 http_response_code(400);
                 break;
         }
     }
     if (isset($result)) {
         $json['body'] = $result->getBody(TRUE);
     }
     header('Content-Type: application/json');
     echo json_encode($json);
 }
開發者ID:htmldriven,項目名稱:cors-proxy,代碼行數:31,代碼來源:RequestHandler.php

示例9: getMessage

 /**
  * {@inheritdoc}
  */
 public function getMessage($id)
 {
     try {
         return $this->guzzle->get('/messages/' . $id . '.json')->send()->json();
     } catch (GuzzleException $e) {
         throw new ConnectionException("", 0, $e);
     }
 }
開發者ID:kibao,項目名稱:mailcatcher,代碼行數:11,代碼來源:GuzzleConnection.php

示例10: put

 /**
  * {@inheritdoc}
  */
 public function put($url, array $headers = array(), array $content = array(), array $files = array())
 {
     $request = $this->client->put($url, $headers, $content);
     foreach ($files as $key => $file) {
         $request->addPostFile($key, $file);
     }
     return $this->sendRequest($request);
 }
開發者ID:widop,項目名稱:http-adapter,代碼行數:11,代碼來源:GuzzleHttpAdapter.php

示例11: loadWsdl

 /**
  * Load remote WSDL to local cache.
  *
  * @param string $url
  * @return string
  */
 public function loadWsdl($url)
 {
     $clientOptions = ['verify' => empty($this->bundleConfig['sync_settings']['skip_ssl_verification'])];
     $response = $this->guzzleClient->get($url, null, $clientOptions)->send();
     $cacheFilePath = $this->getCachedWsdlPath($url);
     $this->fs->dumpFile($cacheFilePath, $response->getBody(true));
     return $cacheFilePath;
 }
開發者ID:heoffice,項目名稱:crm,代碼行數:14,代碼來源:WsdlManager.php

示例12: track

 public function track($trackingNumber)
 {
     try {
         $response = $this->httpClient->post($this->url, array(), array('API' => 'TrackV2', 'XML' => $this->createTrackRequestXml($trackingNumber)))->send();
     } catch (HttpException $e) {
         throw Exception::createFromHttpException($e);
     }
     return $this->parseTrackResponse($response->getBody(true), $trackingNumber);
 }
開發者ID:hautelook,項目名稱:shipment-tracking,代碼行數:9,代碼來源:UspsProvider.php

示例13: track

 public function track($trackingNumber)
 {
     try {
         $response = $this->httpClient->get($this->url, array(), array('query' => array('RQXML' => $this->createRequestXml($trackingNumber))))->send();
     } catch (HttpException $e) {
         throw Exception::createFromHttpException($e);
     }
     return $this->parse($response->getBody(true));
 }
開發者ID:hautelook,項目名稱:shipment-tracking,代碼行數:9,代碼來源:LandmarkProvider.php

示例14: send

 /**
  * @param string $endpoint
  * @param string $content
  * @param array $headers
  * @param array $files
  *
  * @return Response
  */
 public function send($endpoint, $content, array $headers = array(), array $files = array())
 {
     $request = $this->client->createRequest(RequestInterface::POST, $endpoint, $headers, $content, array('exceptions' => false));
     if ($files && $request instanceof EntityEnclosingRequestInterface) {
         $request->addPostFiles($files);
     }
     $response = $request->send();
     return new Response($response->getStatusCode(), $response->getBody(true));
 }
開發者ID:andorpandor,項目名稱:git-deploy.eu2.frbit.com-yr-prototype,代碼行數:17,代碼來源:Guzzle.php

示例15: getByAccessToken

 /**
  * @param string $access_token
  * @return User
  */
 public function getByAccessToken($access_token)
 {
     $me = $this->http->get('https://graph.facebook.com/me?access_token=' . $access_token)->send()->json();
     $data = $this->data_provider->findUserByFacebookId($me['id']);
     $user = null;
     if ($data != null) {
         $user = $this->createUser($data);
     }
     return $user;
 }
開發者ID:shina,項目名稱:control-my-budget,代碼行數:14,代碼來源:UserService.php


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