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


PHP Client::setBaseUrl方法代码示例

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


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

示例1: setHost

 public function setHost($host)
 {
     $this->_host = $host;
     if ($this->_connection) {
         $this->_connection->setBaseUrl($host);
     }
     return $this;
 }
开发者ID:sokil,项目名称:php-rest,代码行数:8,代码来源:Factory.php

示例2: __construct

 /**
  * Creates a Salesforce REST API client that uses username-password authentication
  * @param AuthenticationInterface $authentication
  * @param Http\Client $guzzle
  * @param string $apiRegion The region to use for the Salesforce API.  i.e. na5 or cs30
  * @param string $apiVersion The version of the API to use.  i.e. v31.0
  * @param LoggerInterface $log
  */
 public function __construct(AuthenticationInterface $authentication, Http\Client $guzzle, $apiRegion, $apiVersion = 'v31.0', LoggerInterface $log = null)
 {
     $this->apiBaseUrl = str_replace(array('{region}', '{version}'), array($apiRegion, $apiVersion), static::SALESFORCE_API_URL_PATTERN);
     $this->log = $log ?: new NullLogger();
     $this->authentication = $authentication;
     $this->guzzle = $guzzle;
     $this->guzzle->setBaseUrl($this->apiBaseUrl);
 }
开发者ID:gmo,项目名称:salesforce-rest-api,代码行数:16,代码来源:Client.php

示例3: __construct

 public function __construct($clientId, $clientSecret, $username, $password, $securityToken, Http\Client $guzzle, LoggerInterface $log = null, $loginApiUrl = "https://login.salesforce.com/services/")
 {
     $this->log = $log ?: new NullLogger();
     $this->clientId = $clientId;
     $this->clientSecret = $clientSecret;
     $this->username = $username;
     $this->password = $password;
     $this->securityToken = $securityToken;
     $this->guzzle = $guzzle;
     $this->guzzle->setBaseUrl($loginApiUrl);
 }
开发者ID:gmo,项目名称:salesforce-rest-api,代码行数:11,代码来源:PasswordAuthentication.php

示例4: testClientReturnsValidBaseUrls

 public function testClientReturnsValidBaseUrls()
 {
     $client = new Client('http://www.{foo}.{data}/', array('data' => '123', 'foo' => 'bar'));
     $this->assertEquals('http://www.bar.123/', $client->getBaseUrl());
     $client->setBaseUrl('http://www.google.com/');
     $this->assertEquals('http://www.google.com/', $client->getBaseUrl());
 }
开发者ID:carlesgutierrez,项目名称:libreobjet.org,代码行数:7,代码来源:ClientTest.php

示例5: __construct

 /**
  * Constructor requires final url endpoint to send request to as
  * first parameter. Optional second argument is a client object of type
  * Guzzle\Http\Client.
  *
  *
  * @param string $baseUrl Host to make requests to e.g. https://www.lush.co.uk
  * @param \Guzzle\Http\Client $client Instance of Guzzle client object to use.
  * @param bool $debug If set to true then debug messages will be emitted by the underlying Guzzle client
  */
 public function __construct($baseUrl, \Guzzle\Http\Client $client, $debug = false)
 {
     $this->baseUrl = $baseUrl;
     $client->setBaseUrl($this->baseUrl);
     $this->client = $client;
     $this->debug = (bool) $debug;
 }
开发者ID:gdragffy,项目名称:drupal-oauth-whisperer,代码行数:17,代码来源:Request.php

示例6: call

 /**
  * Returns the response body using the PHP cURL Extension
  * @param Config $config
  * @param string $request_path Request Path/URI
  * @throws HttpException Unable to query server
  */
 public function call(Config $config, $request_path)
 {
     // Setup
     $this->guzzle->setBaseUrl('http://' . $config->getCloudHost());
     $options = array('auth' => explode(':', $config->api_key, 2), 'timeout' => $this->timeout_ms / 1000, 'connect_timeout' => $this->timeout_ms / 1000, 'proxy' => $this->proxy);
     // Compression
     if ($this->use_compression === true) {
         $this->request_headers['Accept-Encoding'] = 'gzip';
     }
     // Execute
     try {
         $request = $this->guzzle->get($request_path, $this->request_headers, $options);
         $response = $request->send();
     } catch (BadResponseException $e) {
         return $this->processGuzzleResponse($e->getResponse());
     } catch (\Exception $e) {
         throw new HttpException("Unable to contact server: Guzzle Error: " . $e->getMessage(), null, $e);
     }
     return $this->processGuzzleResponse($response);
 }
开发者ID:sujata-patne,项目名称:api,代码行数:26,代码来源:Guzzle.php

示例7: __construct

 /**
  * Inject Guzzle in this test class
  * And set up the given client for use on
  * Damn Vulnerable Web Application... A vulnerable application
  * without API...
  * Difficulty resided in finding the way of using
  * cookies and correct documentation for all methods.
  */
 public function __construct()
 {
     parent::__construct();
     //prepare a cookie jar
     $jar = new ArrayCookieJar();
     $cookiePlugin = new CookiePlugin($jar);
     //get a guzzle instance
     $this->_dvwa_guzzle = new Client();
     $this->_dvwa_guzzle->setBaseUrl($this->DVWA_URL);
     $this->_dvwa_guzzle->setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36");
     $this->_dvwa_guzzle->addSubscriber($cookiePlugin);
     //first request/response exchange to get CSRF token
     $request = $this->_dvwa_guzzle->get('login.php', null, ["allow_redirects" => false]);
     $response = $request->send();
     $str = $response->getBody();
     preg_match($this->USER_TOKEN_REGEX, $str, $matches);
     $user_token = $matches[1];
     //second exchange to login
     $request = $this->_dvwa_guzzle->createRequest('POST', 'login.php', null, ['username' => 'admin', 'password' => 'password', 'Login' => 'Login', 'user_token' => $user_token], ["allow_redirects" => true]);
     $request->send();
 }
开发者ID:haterecoil,项目名称:zerowing,代码行数:29,代码来源:PentestControllerTest.php

示例8: createRequest

 /**
  * Function to create a Guzzle HTTP request
  *
  * @param  string $baseUri         The protocol + host
  * @param  string $path            The URI path after the host
  * @param  string $httpMethod      The HTTP method to use for the request (GET, PUT, POST, DELTE etc.)
  * @param  array  $requestHeaders  Any additional headers for the request
  * @param  string $httpMethodParam Post parameter to set with a string that
  *                                 contains the HTTP method type sent with a POST
  * @return RequestManager
  */
 public function createRequest($baseUri, $path, $httpMethod = 'GET', $requestHeaders = array(), $httpMethodParam = null)
 {
     $this->client->setBaseUrl($baseUri);
     if (!in_array(strtolower($httpMethod), array('get', 'put', 'post', 'patch', 'delete', 'head'))) {
         throw new Exception("Invalid HTTP method");
     }
     $method = strtolower($httpMethod);
     $method = $method == 'patch' ? 'put' : $method;
     //override patch calls with put
     if ($httpMethodParam != null && in_array($method, array('put', 'post', 'patch', 'delete'))) {
         $this->request = $this->client->post($path);
         $this->request->setPostField($httpMethodParam, strtoupper($method));
     } else {
         $this->request = $this->client->{$method}($path);
     }
     //set any additional headers on the request
     $this->setHeaders($requestHeaders);
     //setup how we get data back (xml, json etc)
     $this->setTransportLanguage();
     return $this->request;
 }
开发者ID:summer11123,项目名称:trucker,代码行数:32,代码来源:RestRequest.php

示例9: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('neo4j.curl', function ($app) {
         $curl = new Client();
         $curl->setBaseUrl($app['config']->get('neo4j.base_url'));
         return $curl;
     });
     $this->registerCypher();
     $this->registerIndex();
     $this->app->singleton('neo4j', function ($app) {
         return new Neo4jClient($app['neo4j.cypher'], $app['neo4j.index']);
     });
 }
开发者ID:witooh,项目名称:neo4j,代码行数:18,代码来源:Neo4jServiceProvider.php

示例10: createClient

 /**
  * @param string $baseUrl
  * @param ConsumerCredentials $consumerCredentials
  * @param TokenCredentials $tokenCredentials
  *
  * @return Client
  */
 public function createClient($baseUrl, ConsumerCredentials $consumerCredentials, TokenCredentials $tokenCredentials = null)
 {
     $oAuthConfig = array('consumer_key' => $consumerCredentials->getKey(), 'consumer_secret' => $consumerCredentials->getSecret());
     if ($tokenCredentials instanceof TokenCredentials) {
         $oAuthConfig += array('token' => $tokenCredentials->getToken(), 'token_secret' => $tokenCredentials->getSecret());
     }
     $oAuth = new OAuth($oAuthConfig);
     $requestFactory = new JavaHttpRequestFactory();
     $client = new Client();
     $client->setBaseUrl($baseUrl)->addSubscriber($oAuth)->setRequestFactory($requestFactory);
     foreach ($this->subscribers as $subscriber) {
         $client->addSubscriber($subscriber);
     }
     return $client;
 }
开发者ID:cultuurnet,项目名称:auth,代码行数:22,代码来源:DefaultHttpClientFactory.php

示例11: getDeleteResponseFromEndpoint

 /**
  * @param string $queryString
  * @param AbstractEntity $entity
  * @return \Guzzle\http\Message\Response
  * @throws \Searchperience\Common\Http\Exception\EntityNotFoundException
  * @throws \Searchperience\Common\Http\Exception\MethodNotAllowedException
  * @throws \Searchperience\Common\Http\Exception\ForbiddenException
  * @throws \Searchperience\Common\Http\Exception\ClientErrorResponseException
  * @throws \Searchperience\Common\Exception\RuntimeException
  * @throws \Searchperience\Common\Http\Exception\ServerErrorResponseException
  * @throws \Searchperience\Common\Http\Exception\UnauthorizedException
  * @throws \Searchperience\Common\Http\Exception\InternalServerErrorException
  * @throws \Searchperience\Common\Http\Exception\RequestEntityTooLargeException
  */
 protected function getDeleteResponseFromEndpoint($queryString = '', $entity = NULL)
 {
     try {
         $postArray = $entity !== NULL ? $this->buildRequestArray($entity) : array();
         /** @var $response \Guzzle\http\Message\Response */
         $response = $this->restClient->setBaseUrl($this->baseUrl)->delete('/{customerKey}/' . $this->endpoint . $queryString, NULL, $postArray)->setAuth($this->username, $this->password)->send();
     } catch (\Guzzle\Http\Exception\ClientErrorResponseException $exception) {
         $this->transformStatusCodeToClientErrorResponseException($exception);
     } catch (\Guzzle\Http\Exception\ServerErrorResponseException $exception) {
         $this->transformStatusCodeToServerErrorResponseException($exception);
     } catch (\Exception $exception) {
         throw new \Searchperience\Common\Exception\RuntimeException('Unknown error occurred; Please check parent exception for more details.', 1353579284, $exception);
     }
     return $response;
 }
开发者ID:aoemedia,项目名称:searchperience-api-client,代码行数:29,代码来源:AbstractRestBackend.php

示例12: search

 /**
  * @return SearchResultDto
  * @throws \Guzzle\Http\Exception\BadResponseException
  */
 public function search()
 {
     $searchUrl = $this->prepareSearchUrl();
     $response = $this->guzzleClient->setBaseUrl($this->prepareSearchUrl())->get()->send();
     $responseBody = substr($response->getBody(true), 62, -2);
     if (!($responseDecoded = json_decode($responseBody))) {
         throw new BadResponseException('Status code ' . $response->getStatusCode() . ': ' . strip_tags($response->getBody(true)));
     }
     if ($responseDecoded->status == 'error') {
         $errorMessage = [];
         foreach ($responseDecoded->errors as $error) {
             $errorMessage[] = $error->reason . '. ' . $error->message . '. ' . $error->detailed_message;
         }
         throw new BadResponseException(implode(PHP_EOL, $errorMessage));
     }
     return $this->createDto($responseDecoded, $searchUrl);
 }
开发者ID:peak-dev,项目名称:google-trends,代码行数:21,代码来源:Search.php

示例13: __construct

 public function __construct($guzzleClientSvc, $accessToken)
 {
     $this->guzzleClient = $guzzleClientSvc;
     $this->accessToken = $accessToken;
     $this->guzzleClient->setBaseUrl(self::CONTENTFUL_BASE_URL);
 }
开发者ID:rudirocha,项目名称:contentfulBundle,代码行数:6,代码来源:ContentDeliveryService.php

示例14: restoreBaseUrl

 /**
  * Restores the base URL in $client after a cal to setBaseUrl().
  */
 protected function restoreBaseUrl()
 {
     $this->client->setBaseUrl($this->cachedBaseUrl);
 }
开发者ID:nevetS,项目名称:flame,代码行数:7,代码来源:APIObject.php

示例15: setRequestContext

 /**
  * @param \Piece\Questetra\Core\RequestContext $requestContext
  */
 public function setRequestContext(RequestContext $requestContext)
 {
     $this->requestContext = $requestContext;
     $this->httpClient->setBaseUrl($this->requestContext->getContextRoot());
 }
开发者ID:piece,项目名称:piece-questetra,代码行数:8,代码来源:QuestetraClient.php


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