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