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


PHP Client::get方法代码示例

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


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

示例1: getRequestData

 /**
  * Выполняет запрос к API и возвращает json ответа
  *
  * @param $api
  * @param array $options
  * @return mixed
  */
 public function getRequestData($api, array $options = [])
 {
     $headers = [];
     $response = $this->client->get($api, $headers, $options)->send();
     //todo throw exception if status != 200 and log it
     $result = json_decode($response->getBody(), true);
     return $result;
 }
开发者ID:Zlob,项目名称:SkillCompass,代码行数:15,代码来源:ApiRequest.php

示例2: get

 /**
  * Send a GET request
  * 
  * @param string $uri
  * @return \Guzzle\Http\Message\Response
  */
 public function get($uri)
 {
     // add the authorization header
     $headers['Authorization'] = "Bearer {$this->_generateBearerToken()}";
     $headers['X-ApplicationId'] = $this->appId;
     $response = $this->client->get($uri, $headers)->setAuth('developers.chromedia', 'cfe-developers', 'Bearer')->send();
     return $response;
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:14,代码来源:ChromediaGlobalRequest.php

示例3: downloadTorrent

 public function downloadTorrent($torrentId)
 {
     $request = $this->restClient->get(self::T411_API_BASE_URL . '/torrents/download/' . $torrentId);
     $request->addHeader('Authorization', $this->token);
     $response = $request->send();
     $result = $response->getBody(true);
     $this->handleResponse($result);
     //Enregistre le torrent quelque part
     $detailsTorrent = $this->torrentDetails($torrentId);
     $torrentPath = $this->tmpFolder . '/' . $detailsTorrent->rewritename . '.torrent';
     file_put_contents($torrentPath, $result);
     return $torrentPath;
 }
开发者ID:elpiafo3,项目名称:Torrent-Streamer,代码行数:13,代码来源:T411RestClient.php

示例4: execute

 /**
  * Execute the query.
  *
  * @param string $url
  * @param array  $params
  *
  * @return string|boolean
  */
 public function execute($url, $params = [])
 {
     $uri = rtrim(rtrim($this->site, '/') . '/' . ltrim($url, '/') . '?' . http_build_query($params), '?');
     try {
         $result = $this->client->get($uri, ['timeout' => 10])->getBody(true);
         return $this->format === 'json' ? json_decode($result) : (string) $result;
     } catch (\Exception $e) {
         if ($this->isRetry) {
             return false;
         }
         $this->isRetry = true;
         $this->site = str_replace('https://', 'http://', $this->site);
         return $this->execute($url, $params);
     }
 }
开发者ID:Johardmeier,项目名称:bolt,代码行数:23,代码来源:ExtensionsInfoService.php

示例5: productAction

 public function productAction()
 {
     $client = new Client('http://stroyka.by');
     $request = $client->get('/');
     $request->send();
     $resault = $request->getResponse()->getBody(true);
     $crawler = new Crawler();
     //        $crawler->addHTMLContent($resault);
     //        $res = $request->getResponse()->getH;
     //        var_dump($res);exit();
     //        $text = utf8_decode($resault);
     $crawler = new Crawler($resault);
     $resault = $crawler->filter('ul.b-categories')->html();
     //
     //
     //        $crowler2 = new Crawler($resault);
     //
     //        $resault = $crowler2->filter('span.b-categories__name');
     //
     //        $nodeValues = $crawler->filter('span.b-categories__name')->each(function (Crawler $node, $i) {
     //            return utf8_decode($node->text());
     //        });
     //        var_dump(mb_detect_encoding($nodeValues[0]));exit();
     //        foreach($nodeValues as $nv) {
     //            $category = new Category();
     //            $category->setName($nv);
     //            $this->getDoctrine()->getManager()->persist($category);
     //        }
     //        $this->getDoctrine()->getManager()->flush();
     //        var_dump($nodeValues);
     //        var_dump($resault);
     //        exit;
     return $this->render('AcmeAppBundle:Default:product.html.twig', array('result' => $resault));
 }
开发者ID:Tugart,项目名称:parser,代码行数:34,代码来源:DefaultController.php

示例6: execute

 /**
  * Execute the query.
  *
  * @param string $url
  * @param array  $params
  *
  * @return string|boolean
  */
 public function execute($url, $params = [])
 {
     $uri = rtrim(rtrim($this->site, '/') . '/' . ltrim($url, '/') . '?' . http_build_query($params), '?');
     try {
         $result = $this->client->get($uri, ['timeout' => 10])->getBody(true);
         return $this->format === 'json' ? json_decode($result) : (string) $result;
     } catch (\Exception $e) {
         if ($this->isRetry) {
             $msg = "Error connecting to the Extension Marketplace:\n" . $e->getMessage();
             throw new ExtensionsInfoServiceException($msg, $e->getCode(), $e);
         }
         $this->isRetry = true;
         $this->site = str_replace('https://', 'http://', $this->site);
         return $this->execute($url, $params);
     }
 }
开发者ID:nectd,项目名称:nectd-web,代码行数:24,代码来源:ExtensionsInfoService.php

示例7: resolve

 public function resolve()
 {
     $deps = array($this->package);
     $resolved = array();
     $guzzle = new Client('http://packagist.org');
     while (count($deps) > 0) {
         $package = $this->rename(array_pop($deps));
         if (!$package) {
             continue;
         }
         try {
             $response = $guzzle->get('/packages/' . $package . '.json')->send()->getBody(true);
         } catch (\Exception $e) {
             continue;
         }
         $package = json_decode($response);
         if (!is_null($package)) {
             foreach ($package->package->versions as $version) {
                 if (!isset($version->require)) {
                     continue;
                 }
                 foreach ($version->require as $dependency => $version) {
                     if (!in_array($dependency, $resolved) && !in_array($dependency, $deps)) {
                         $deps[] = $dependency;
                         $deps = array_unique($deps);
                     }
                 }
             }
             echo "   * Package {$package->package->name} was added\n";
             $resolved[] = $package->package->name;
         }
     }
     return $resolved;
 }
开发者ID:matsinet,项目名称:medusa,代码行数:34,代码来源:DependencyResolver.php

示例8: getDigest

 /**
  * Get digest credits
  */
 public function getDigest($date)
 {
     $client = new Client('https://graph.facebook.com/oauth/access_token?client_id={company_id}&client_secret={company_secret}&grant_type=client_credentials', array('company_id' => $this->companyId, 'company_secret' => $this->companySecret));
     $response = $client->get()->send();
     if (200 !== $response->getStatusCode()) {
         throw new Exception("Can't get access token using passed company id and secret");
     }
     $token = $response->getBody();
     parse_str($token);
     $dailyDigestUrl = "https://paymentreports.facebook.com/{company_id}/report?date={date}&type=digest&access_token={access_token}";
     $client = new Client($dailyDigestUrl, array('company_id' => $this->companyId, 'access_token' => $access_token, 'date' => $date));
     $response = $client->get()->send();
     if (200 !== $response->getStatusCode()) {
         throw new \Exception("Can't download daily detail report");
     }
     $cacheDir = $this->container->get('kernel')->getRootDir() . '/cache';
     $extractDir = $cacheDir . '/tmp-facebook-report';
     @mkdir($extractDir, 0755, true);
     $zipFileName = tempnam($extractDir, "fb_detail_report") . ".zip";
     file_put_contents($zipFileName, $response->getBody());
     $zip = new \ZipArchive();
     if ($zip->open($zipFileName) === TRUE) {
         $zip->extractTo($extractDir);
         $zip->close();
         @unlink($zipFileName);
         $finder = new Finder();
         $finder->files()->name($this->companyId . '_digest_*.csv')->in($extractDir);
         foreach ($finder as $file) {
             $stop = true;
             $header = array();
             $rows = array();
             foreach (file($file->getRealpath()) as $line) {
                 if (preg_match('/^SH.*credits_digest$/', $line)) {
                     $stop = false;
                     continue;
                 }
                 if (preg_match('/^SF/', $line)) {
                     $stop = true;
                     continue;
                 }
                 if (preg_match('/^CH/', $line)) {
                     $line = preg_replace('/^CH,/', '', $line);
                     $header = str_getcsv($line);
                     continue;
                 }
                 if (!$stop) {
                     $line = preg_replace('/^SD,/', '', $line);
                     $columns = str_getcsv($line);
                     $row = array_combine($header, $columns);
                     $rows[] = $row;
                 }
             }
             @unlink($file->getRealpath());
             return $rows;
         }
     } else {
         throw new Exception("Can't unzip facebook report archive");
     }
 }
开发者ID:rodchyn,项目名称:facebook-report-parser,代码行数:62,代码来源:Parser.php

示例9: getData

 protected function getData()
 {
     $client = new Client();
     $response = $client->get(static::DATA_SOURCE_URL)->send();
     if (200 !== $response->getStatusCode()) {
         throw new RemoteServerProblem('Data is not available');
     }
     return $this->convertData(json_decode($response->getBody(), true));
 }
开发者ID:RomanUi,项目名称:TestTask,代码行数:9,代码来源:MoviesController.php

示例10: execute

 /**
  * Execute the query.
  *
  * @param string $url
  * @param array  $params
  *
  * @return string|boolean
  */
 public function execute($url, $params = array())
 {
     $uri = rtrim(rtrim($this->site, '/') . '/' . ltrim($url, '/') . '?' . http_build_query($params), '?');
     try {
         if ($this->deprecated) {
             /** @deprecated remove when PHP 5.3 support is dropped */
             $result = $this->client->get($uri, array('timeout' => 10))->send()->getBody(true);
         } else {
             $result = $this->client->get($uri, array('timeout' => 10))->getBody(true);
         }
         return $this->format === 'json' ? json_decode($result) : (string) $result;
     } catch (\Exception $e) {
         if ($this->isRetry) {
             return false;
         }
         $this->isRetry = true;
         $this->site = str_replace('https://', 'http://', $this->site);
         return $this->execute($url, $params);
     }
 }
开发者ID:aaleksu,项目名称:bolt_cm,代码行数:28,代码来源:ExtensionsInfoService.php

示例11: getContent

    /**
     * {@inheritDoc}
     */
    public function getContent($url)
    {
        $guzzle = new Client();

        try {
            $content = (string) $guzzle->get($url)->send()->getBody();
        } catch (\Exception $e) {
            $content = null;
        }

        return $content;
    }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:15,代码来源:GuzzleHttpAdapter.php

示例12: execute

 /**
  * Execute the query.
  *
  * @param string $url
  * @param array  $params
  *
  * @return string|boolean
  */
 public function execute($url, $params = array())
 {
     $uri = rtrim(rtrim($this->site, '/') . '/' . ltrim($url, '/') . '?' . http_build_query($params), '?');
     try {
         if ($this->deprecated) {
             /** @deprecated remove when PHP 5.3 support is dropped */
             $result = $this->client->get($uri, array('timeout' => 10))->send()->getBody(true);
         } else {
             $result = $this->client->get($uri, array('timeout' => 10))->getBody(true);
         }
         return $this->format === 'json' ? json_decode($result) : (string) $result;
     } catch (\Exception $e) {
         if ($this->isRetry) {
             $msg = "Error connecting to the Extension Marketplace:\n" . $e->getMessage();
             throw new ExtensionsInfoServiceException($msg, $e->getCode(), $e);
         }
         $this->isRetry = true;
         $this->site = str_replace('https://', 'http://', $this->site);
         return $this->execute($url, $params);
     }
 }
开发者ID:aleksabp,项目名称:bolt,代码行数:29,代码来源:ExtensionsInfoService.php

示例13: getFile

 /**
  * @param string $relation
  * @param array  $parameters
  * @throws ClientErrorResponseException
  * @return Navigator|array|string|int|bool|float
  */
 public function getFile($relation, array $parameters = [])
 {
     $templatedUrl = $this->getRelation($relation);
     $url = $this->renderUri($templatedUrl, $parameters);
     try {
         $request = $this->guzzleClient->get($url);
         $query = $this->guzzleClient->send($request);
     } catch (ClientErrorResponseException $e) {
         throw $e;
     }
     return (string) $query->getBody();
 }
开发者ID:ArDeveloppement,项目名称:HALRestClient,代码行数:18,代码来源:Client.php

示例14: execute

 public function execute(Request $request)
 {
     $guzzle = new GuzzleClient();
     if ($request->getVerb() == 'GET') {
         $guzzleRequest = $guzzle->get($request->getUrlWithQueryString());
     }
     if ($request->getHeader()) {
         list($headerName, $headerValue) = $request->getHeader();
         $guzzleRequest->setHeader($headerName, $headerValue);
     }
     $this->response = $guzzleRequest->send();
     return $this->getBody();
 }
开发者ID:eher,项目名称:chegamos-lib,代码行数:13,代码来源:Guzzle.php

示例15: fetchUserDetails

 protected function fetchUserDetails(AccessToken $token, $force = true)
 {
     $url = $this->urlUserDetails($token);
     try {
         $client = new GuzzleClient();
         $request = $client->get($url, array('Authorization' => 'Bearer ' . $token));
         $response = $request->send();
         $xml_response = $response->xml();
     } catch (BadResponseException $e) {
         $raw_response = explode("\n", $e->getResponse());
         throw new IDPException(end($raw_response));
     }
     return $xml_response;
 }
开发者ID:deminoth,项目名称:oauth2-naver,代码行数:14,代码来源:Naver.php


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