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


PHP Client::getBaseUrl方法代码示例

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


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

示例1: injectScript

 /**
  * Injects the livereload script.
  *
  * @param Response $response A Response instance
  */
 protected function injectScript(Response $response)
 {
     if (function_exists('mb_stripos')) {
         $posrFunction = 'mb_strripos';
         $substrFunction = 'mb_substr';
     } else {
         $posrFunction = 'strripos';
         $substrFunction = 'substr';
     }
     $content = $response->getContent();
     $pos = $posrFunction($content, '</body>');
     if (false !== $pos) {
         $script = "livereload.js";
         if ($this->checkServerPresence) {
             // GET is required, as livereload apparently does not support HEAD requests ...
             $request = $this->httpClient->get($script);
             try {
                 $checkResponse = $this->httpClient->send($request);
                 if ($checkResponse->getStatusCode() !== 200) {
                     return;
                 }
             } catch (CurlException $e) {
                 // If error is connection failed, we assume the server is not running
                 if ($e->getCurlHandle()->getErrorNo() === 7) {
                     return;
                 }
                 throw $e;
             }
         }
         $content = $substrFunction($content, 0, $pos) . "\n" . '<script src="' . $this->httpClient->getBaseUrl() . $script . '"></script>' . "\n" . $substrFunction($content, $pos);
         $response->setContent($content);
     }
 }
开发者ID:bakie,项目名称:KunstmaanBundlesCMS,代码行数:38,代码来源:ScriptInjectorListener.php

示例2: delete

 /**
  * @param string $id
  */
 public function delete($id)
 {
     $url = $this->getConnectionUrl($id);
     $request = $this->client->delete($this->client->getBaseUrl() . $url, $this->HEADERS);
     $response = $request->send();
     $this->statusCodeValidator->validate(200, $url, $request, $response);
 }
开发者ID:janus-ssp,项目名称:client,代码行数:10,代码来源:ConnectionRepository.php

示例3: findAll

 /**
  * @return Connection[]
  */
 public function findAll()
 {
     $url = $this->getConnectionsUrl();
     $request = $this->client->get($this->client->getBaseUrl() . $url);
     $response = $request->send();
     $this->statusCodeValidator->validate(200, $url, $request, $response);
     return $this->mapJsonToConnectionDescriptors($response->getBody(true));
 }
开发者ID:janus-ssp,项目名称:client,代码行数:11,代码来源:ConnectionDescriptorRepository.php

示例4: get

 /**
  * Get data
  *
  * @param string $request
  *
  * @return array
  */
 protected function get($request)
 {
     $response = $this->client->get($this->prefix . $this->getLocale() . $request)->send();
     if ($response->isError()) {
         throw new \RuntimeException('Failed execute request "' . $request . '" to the server "' . $this->client->getBaseUrl() . '"');
     }
     return json_decode($response->getBody(true), true);
 }
开发者ID:anime-db,项目名称:api-client-bundle,代码行数:15,代码来源:Client.php

示例5: get

 /**
  * Get data from path.
  *
  * @param string $path
  *
  * @return array
  */
 public function get($path)
 {
     $response = $this->client->get($this->api_prefix . $path)->send();
     if ($response->isError()) {
         throw new \RuntimeException('Failed to query the server ' . $this->client->getBaseUrl());
     }
     $body = json_decode($response->getBody(true), true);
     if (json_last_error() !== JSON_ERROR_NONE || !is_array($body)) {
         throw new \RuntimeException('Invalid response from the server ' . $this->client->getBaseUrl());
     }
     return $body;
 }
开发者ID:anime-db,项目名称:shikimori-browser-bundle,代码行数:19,代码来源:Browser.php

示例6: getBaseUrl

 public function getBaseUrl($expand = true)
 {
     $baseUrl = parent::getBaseUrl(false);
     $url = $baseUrl;
     if ($this->tokens instanceof AccessToken) {
         $url .= strpos($url, '?') ? '&' : '?';
         $url .= http_build_query(array('access_token' => $this->tokens->access_token));
     }
     $this->setBaseUrl($url);
     $return = parent::getBaseUrl($expand);
     $this->setBaseUrl($baseUrl);
     return $return;
 }
开发者ID:chrisnharvey,项目名称:oauth2,代码行数:13,代码来源:Client.php

示例7: testCreatesRequestsWithDefaultValues

 public function testCreatesRequestsWithDefaultValues()
 {
     $client = new Client($this->getServer()->getUrl() . 'base');
     // Create a GET request
     $request = $client->createRequest();
     $this->assertEquals('GET', $request->getMethod());
     $this->assertEquals($client->getBaseUrl(), $request->getUrl());
     // Create a DELETE request
     $request = $client->createRequest('DELETE');
     $this->assertEquals('DELETE', $request->getMethod());
     $this->assertEquals($client->getBaseUrl(), $request->getUrl());
     // Create a HEAD request with custom headers
     $request = $client->createRequest('HEAD', 'http://www.test.com/');
     $this->assertEquals('HEAD', $request->getMethod());
     $this->assertEquals('http://www.test.com/', $request->getUrl());
     // Create a PUT request
     $request = $client->createRequest('PUT');
     $this->assertEquals('PUT', $request->getMethod());
     // Create a PUT request with injected config
     $client->getConfig()->set('a', 1)->set('b', 2);
     $request = $client->createRequest('PUT', '/path/{a}?q={b}');
     $this->assertEquals($request->getUrl(), $this->getServer()->getUrl() . 'path/1?q=2');
 }
开发者ID:carlesgutierrez,项目名称:libreobjet.org,代码行数:23,代码来源:ClientTest.php

示例8: setBaseUrl

 /**
  * Overwrites the base URL defined in $client.
  * You can restore the base URL by calling restoreBaseUrl().
  *
  * @param string $base_url
  */
 protected function setBaseUrl($base_url)
 {
     $this->cachedBaseUrl = $this->client->getBaseUrl();
     $base_url = rtrim($this->config->endpoint, '/') . '/' . ltrim($base_url, '/');
     $this->client->setBaseUrl($base_url);
 }
开发者ID:nevetS,项目名称:flame,代码行数:12,代码来源:APIObject.php

示例9: getBaseUri

 public function getBaseUri()
 {
     return $this->client->getBaseUrl();
 }
开发者ID:canaltp,项目名称:abstract-guzzle,代码行数:4,代码来源:Guzzle3.php

示例10: setLatence

 private function setLatence(BaseClient $client)
 {
     $latenceClient = new BaseClient($client->getBaseUrl());
     $response = $latenceClient->get('auth/time')->send();
     $this->latence = time() - (int) $response->getBody(true);
 }
开发者ID:yoye,项目名称:ovh-sdk,代码行数:6,代码来源:Plugin.php

示例11: setId

 protected function setId($str)
 {
     $str = str_replace($this->curl->getBaseUrl() . $this->uri . '/', '', $str);
     $str = str_replace('/commit', '', $str);
     $this->id = $str;
 }
开发者ID:witooh,项目名称:neo4j,代码行数:6,代码来源:Transaction.php


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