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


PHP ClientInterface::get方法代码示例

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


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

示例1: get

 public function get($url)
 {
     if (!$this->isValidArgument($url)) {
         throw new \InvalidArgumentException('Supply a valid URL please.');
     }
     return $this->guzzle->get($url);
 }
开发者ID:dwickstrom,项目名称:moz,代码行数:7,代码来源:GuzzleClient.php

示例2: get

 /**
  * Executa uma requisição GET.
  *
  * @param $part
  * @param array $data
  * @param array $headers
  * @return mixed
  */
 public function get($part, $data = [], array $headers = [])
 {
     $opts = ['headers' => array_merge([], $this->headers, $headers)];
     $part = uri_params($part, $data);
     $response = new Response($this->client->get($part, $opts));
     return $response->make();
 }
开发者ID:bugotech,项目名称:rfm,代码行数:15,代码来源:GenericConnection.php

示例3: execute

 /**
  * Execute an operaction
  *
  * A successful operation will return result as an array.
  * An unsuccessful operation will return null.
  *
  * @param  OperationInterface $op
  * @return array|null
  */
 public function execute(OperationInterface $op)
 {
     try {
         if ($op instanceof DeleteOperationInterface) {
             $response = $this->httpClient->delete($op->getEndpoint(), ['headers' => $op->getHeaders()]);
         } elseif ($op instanceof PostOperationInterface) {
             $response = $this->httpClient->post($op->getEndpoint(), ['headers' => $op->getHeaders(), 'body' => $op->getData()]);
         } elseif ($op instanceof PatchOperationInterface) {
             $response = $this->httpClient->patch($op->getEndpoint(), ['headers' => $op->getHeaders(), 'body' => $op->getData()]);
         } elseif ($op instanceof PutOperationInterface) {
             $response = $this->httpClient->put($op->getEndpoint(), ['headers' => $op->getHeaders(), 'body' => $op->getData()]);
         } else {
             $response = $this->httpClient->get($op->getEndpoint());
         }
     } catch (GuzzleHttp\Exception\ClientException $e) {
         throw new Exception\ClientException('ClientException occurred in request to Orchestrate: ' . $e->getMessage(), $e->getCode(), $e);
     } catch (GuzzleHttp\Exception\ServerException $e) {
         throw new Exception\ServerException('ServerException occurred in request to Orchestrate: ' . $e->getMessage(), $e->getCode(), $e);
     }
     $refLink = null;
     $location = null;
     if ($response->hasHeader('ETag')) {
         $refLink = str_replace('"', '', $response->getHeaderLine('ETag'));
     } elseif ($response->hasHeader('Link')) {
         $refLink = str_replace(['<', '>; rel="next"'], ['', ''], $response->getHeaderLine('Link'));
     }
     if ($response->hasHeader('Location')) {
         $location = $response->getHeaderLine('Location');
     }
     $rawValue = $response->getBody(true);
     $value = json_decode($rawValue, true);
     return $op->getObjectFromResponse($refLink, $location, $value, $rawValue);
 }
开发者ID:absynthe,项目名称:orchestrate-php-client,代码行数:42,代码来源:Client.php

示例4: getRequest

 /**
  * @since 0.2
  * @param Request $request
  * @return mixed
  */
 public function getRequest(Request $request)
 {
     $resultArray = $this->client->get(null, array('query' => array_merge($request->getParams(), array('format' => 'json')), 'headers' => $request->getHeaders()))->json();
     $this->triggerErrors($resultArray);
     $this->throwUsageExceptions($resultArray);
     return $resultArray;
 }
开发者ID:alxmsl,项目名称:mediawiki-api-base,代码行数:12,代码来源:MediawikiApi.php

示例5: getQueue

 /**
  * @param string $vhost
  * @param string $name
  * @param int    $interval
  *
  * @return array
  */
 public function getQueue($vhost, $name, $interval = 30)
 {
     $queueName = sprintf('%s/%s', urlencode($vhost), urlencode($name));
     $url = sprintf('http://%s:%d/api/queues/%s?%s', $this->hostname, $this->port, $queueName, http_build_query(['lengths_age' => $interval, 'lengths_incr' => $interval, 'msg_rates_age' => $interval, 'msg_rates_incr' => $interval, 'data_rates_age' => $interval, 'data_rates_incr' => $interval]));
     $response = $this->httpClient->get($url, ['auth' => [$this->user, $this->password]]);
     return $response->json();
 }
开发者ID:sroze,项目名称:tolerance,代码行数:14,代码来源:RabbitMqHttpClient.php

示例6: denormalize

 /**
  * {@inheritdoc}
  */
 public function denormalize($data, $class, $format = NULL, array $context = array())
 {
     $file_data = (string) $this->httpClient->get($data['uri'][0]['value'])->getBody();
     $path = 'temporary://' . drupal_basename($data['uri'][0]['value']);
     $data['uri'] = file_unmanaged_save_data($file_data, $path);
     return $this->entityManager->getStorage('file')->create($data);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:10,代码来源:FileEntityNormalizer.php

示例7: downloadFile

 /**
  * Download a package file.
  *
  * @param string $path
  * @param string $url
  * @param string $shasum
  */
 public function downloadFile($path, $url, $shasum = '')
 {
     $file = $path . '/' . uniqid();
     try {
         $data = $this->client->get($url)->getBody();
         if ($shasum && sha1($data) !== $shasum) {
             throw new ChecksumVerificationException("The file checksum verification failed");
         }
         if (!$this->files->makeDir($path) || !$this->files->putContents($file, $data)) {
             throw new NotWritableException("The path is not writable ({$path})");
         }
         if (Zip::extract($file, $path) !== true) {
             throw new ArchiveExtractionException("The file extraction failed");
         }
         $this->files->delete($file);
     } catch (\Exception $e) {
         $this->files->delete($path);
         if ($e instanceof TransferException) {
             if ($e instanceof BadResponseException) {
                 throw new UnauthorizedDownloadException("Unauthorized download ({$url})");
             }
             throw new DownloadErrorException("The file download failed ({$url})");
         }
         throw $e;
     }
 }
开发者ID:jacobjjc,项目名称:PageKit-framework,代码行数:33,代码来源:PackageDownloader.php

示例8: fetchPageContentFor

 /**
  * Scrape and fetch page content for the provided link
  *
  * @param $link
  * @return string
  */
 public function fetchPageContentFor($link)
 {
     // We need to enable cookie to be able to get the proper page source
     $cookieJar = new CookieJar();
     $response = $this->guzzleClient->get($link, ['cookies' => $cookieJar]);
     return (string) $response->getBody();
 }
开发者ID:dilipgurung,项目名称:sainsburys-page-scraper,代码行数:13,代码来源:LinkScraper.php

示例9: getListTasks

 /**
  * Return all the tasks of a given list
  *
  * @param int $list_id
  *
  * @return array()
  */
 public function getListTasks($list_id)
 {
     if (!is_numeric($list_id)) {
         throw new \InvalidArgumentException('The list id must be numeric.');
     }
     $response = $this->client->get('tasks', ['query' => ['list_id' => $list_id]]);
     $this->checkResponseStatusCode($response, 200);
     return json_decode($response->getBody());
 }
开发者ID:e-tipalchuk,项目名称:wunderlist-api-demo,代码行数:16,代码来源:WunderlistClient.php

示例10: download

 /**
  * @param $url
  * @return string
  * @throws HttpClientException
  */
 public function download($url)
 {
     $response = $this->guzzlClient->get($url);
     if (200 == $response->getStatusCode()) {
         $body = $response->getBody();
         return $this->saveBodyAsFile($body);
     }
     throw new HttpClientException(sprintf('Unable to get download from "%s"', $url));
 }
开发者ID:msiebeneicher,项目名称:phar-self-updater,代码行数:14,代码来源:GuzzlApapter.php

示例11: get

 /**
  * @param $action
  * @param array $options
  * @return mixed
  * @throws \Exception
  */
 public function get($action, array $options)
 {
     $requestOptions = $this->buildRequestOptions($action, $options);
     try {
         $response = $this->connection->get($this->api_url, ['headers' => $requestOptions['headers'], 'cookies' => $requestOptions['cookies'], 'query' => $requestOptions['query']]);
     } catch (RequestException $e) {
         throw new \Exception($e->getMessage(), $e->getCode(), $e);
     }
     return $response->json();
 }
开发者ID:Git-Host,项目名称:GuerrillaMail,代码行数:16,代码来源:GuzzleConnection.php

示例12: sendRequest

 /**
  * send a request to pugme api
  *
  * @param string $url
  * @return mixed
  * @throws PugNotFoundException
  */
 private function sendRequest($url)
 {
     try {
         $response = $this->client->get($this->baseUrl . $url);
         $pug = json_decode($response->getBody(), true);
     } catch (Exception $e) {
         throw new PugNotFoundException();
     }
     return $pug;
 }
开发者ID:olyckne,项目名称:pug,代码行数:17,代码来源:Pug.php

示例13: get

 /**
  * Fetch the media items.
  *
  * @param string $user
  *
  * @throws \Vinkla\Instagram\InstagramException
  *
  * @return array
  */
 public function get(string $user) : array
 {
     try {
         $url = sprintf('https://www.instagram.com/%s/media', $user);
         $response = $this->client->get($url);
         return json_decode((string) $response->getBody(), true)['items'];
     } catch (RequestException $e) {
         throw new InstagramException(sprintf('The user [%s] was not found.', $user));
     }
 }
开发者ID:vinkla,项目名称:instagram,代码行数:19,代码来源:Instagram.php

示例14: profileApi

 public function profileApi($uuid)
 {
     $response = $this->client->get(sprintf(static::PROFILE_API, $uuid))->json(array('object' => true));
     if (!$response) {
         throw new \RuntimeException('Bad UUID ' . $uuid);
     } elseif (isset($response->error)) {
         throw new \RuntimeException('Error from API: ' . $response->error . ' on UUID ' . $uuid);
     }
     return $response;
 }
开发者ID:kyroskoh,项目名称:MinecraftProfile,代码行数:10,代码来源:ApiClient.php

示例15: get

 /**
  * {@inheritdoc}
  */
 public function get($url)
 {
     try {
         $this->response = $this->client->get($url);
     } catch (RequestException $e) {
         $this->response = $e->getResponse();
         $this->handleError();
     }
     return $this->response->getBody();
 }
开发者ID:softr,项目名称:asaas-php-sdk,代码行数:13,代码来源:GuzzleHttpAdapter.php


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