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


PHP Client::setConfig方法代码示例

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


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

示例1: lookupAddress

 /**
  * @param string $postalCode
  * @param string $houseNumber
  * @return array
  */
 public function lookupAddress($postalCode, $houseNumber)
 {
     $this->client->setConfig(['curl.options' => ['CURLOPT_CONNECTTIMEOUT_MS' => '2000', 'CURLOPT_RETURNTRANSFER' => true]]);
     $url = sprintf($this->baseUrl . '/%s/%s', $postalCode, $houseNumber);
     $request = $this->client->get($url)->setAuth($this->apiKey, $this->apiSecret);
     return $request->send()->json();
 }
开发者ID:dannyvw,项目名称:laravel-postcodenl,代码行数:12,代码来源:Postcodenl.php

示例2: accessTokenRequest

 /**
  *
  * @param array $p
  * @return bool|TokenResponse
  */
 protected function accessTokenRequest(array $p)
 {
     $this->c->setConfig(array(\Guzzle\Http\Client::REQUEST_OPTIONS => array('allow_redirects' => false, 'exceptions' => false, 'verify' => false)));
     if ($this->clientConfig->getCredentialsInRequestBody()) {
         // provide credentials in the POST body
         $p['client_id'] = $this->clientConfig->getClientId();
         $p['client_secret'] = $this->clientConfig->getClientSecret();
     } else {
         // use basic authentication
         $curlAuth = new \Guzzle\Plugin\CurlAuth\CurlAuthPlugin($this->clientConfig->getClientId(), $this->clientConfig->getClientSecret());
         $this->c->addSubscriber($curlAuth);
     }
     try {
         $request = $this->c->post($this->clientConfig->getTokenEndpoint());
         $request->addPostFields($p);
         $request->addHeader('Accept', 'application/json');
         $responseData = $request->send()->json();
         // some servers do not provide token_type, so we allow for setting
         // a default
         // issue: https://github.com/fkooman/php-oauth-client/issues/13
         if (null !== $this->clientConfig->getDefaultTokenType()) {
             if (is_array($responseData) && !isset($responseData['token_type'])) {
                 $responseData['token_type'] = $this->clientConfig->getDefaultTokenType();
             }
         }
         // if the field "expires_in" has the value null, remove it
         // issue: https://github.com/fkooman/php-oauth-client/issues/17
         if ($this->clientConfig->getAllowNullExpiresIn()) {
             if (is_array($responseData) && array_key_exists("expires_in", $responseData)) {
                 if (null === $responseData['expires_in']) {
                     unset($responseData['expires_in']);
                 }
             }
         }
         // if the field "scope" is empty string a default can be set
         // through the client configuration
         // issue: https://github.com/fkooman/php-oauth-client/issues/20
         if (null !== $this->clientConfig->getDefaultServerScope()) {
             if (is_array($responseData) && isset($responseData['scope']) && '' === $responseData['scope']) {
                 $responseData['scope'] = $this->clientConfig->getDefaultServerScope();
             }
         }
         return new TokenResponse($responseData);
     } catch (\Guzzle\Common\Exception\RuntimeException $e) {
         return false;
     }
 }
开发者ID:petboys,项目名称:APIWholesale,代码行数:52,代码来源:CodesWholesaleTokenRequest.php

示例3: testAllowsConfigsToBeChangedAndInjectedInBaseUrl

 public function testAllowsConfigsToBeChangedAndInjectedInBaseUrl()
 {
     $client = new Client('http://{a}/{b}');
     $this->assertEquals('http:///', $client->getBaseUrl());
     $this->assertEquals('http://{a}/{b}', $client->getBaseUrl(false));
     $client->setConfig(array('a' => 'test.com', 'b' => 'index.html'));
     $this->assertEquals('http://test.com/index.html', $client->getBaseUrl());
 }
开发者ID:carlesgutierrez,项目名称:libreobjet.org,代码行数:8,代码来源:ClientTest.php

示例4: sendRequest

 /**
  * Makes http request to remote host.
  *
  * @param string $url
  * @param mixed  $data
  * @param array $options
  *
  * @throws \ErrorException|\Exception
  * @return mixed
  */
 protected function sendRequest($url, $data, $options = null)
 {
     $client = new HttpClient();
     $client->setConfig(array('curl.options' => array(CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false)));
     $request = $client->post($url, null, $data);
     try {
         return $request->send()->getBody();
     } catch (RequestException $e) {
         throw new CommunicationError('Communication failed: ' . $url);
     }
 }
开发者ID:paranoiaproject,项目名称:paranoia,代码行数:21,代码来源:AdapterAbstract.php

示例5: setGuzzleConfig

 /**
  * @param array|\Guzzle\Common\Collection $config
  * @return Client $this
  */
 public function setGuzzleConfig($config)
 {
     $this->client->setConfig($config);
     return $this;
 }
开发者ID:webaction,项目名称:php-geckoboard-api,代码行数:9,代码来源:Client.php

示例6: DatabaseConfiguration

    $configuration['database'] = $processor->processConfiguration(new DatabaseConfiguration(), array($database));
    $configuration['mailer'] = $processor->processConfiguration(new MailerConfiguration(), array($mailer));
    $configuration['leboncoin'] = $processor->processConfiguration(new LeboncoinConfiguration(), array($leboncoin));
    return $configuration;
};
$app['db'] = function ($app) {
    $config = $app['configuration']['database']['connection'];
    if (isset($config['path'])) {
        $config['path'] = substr($config['path'], 0, 1) == '/' ? $config['path'] : __DIR__ . '/../' . $config['path'];
    }
    return DriverManager::getConnection($config, new Configuration());
};
$app['guzzle'] = function ($app) {
    $guzzle = new GuzzleClient($app['configuration']['leboncoin']['url']);
    if (null !== ($proxy = $app['configuration']['leboncoin']['proxy'])) {
        $guzzle->setConfig(array('request.options' => array('proxy' => $proxy)));
    }
    return $guzzle;
};
$app['client'] = function ($app) {
    return new LeboncoinClient($app['guzzle']);
};
$app['bid.manager'] = function ($app) {
    return new BidManager($app['db']);
};
$app['alert.manager'] = function ($app) {
    return new AlertManager($app['db']);
};
$app['twig'] = function ($app) {
    $loader = new \Twig_Loader_Filesystem(__DIR__ . '/../templates');
    return new \Twig_Environment($loader);
开发者ID:inscriptionweb,项目名称:leboncoin-cli,代码行数:31,代码来源:container.php

示例7: getClient

 /**
  * Instantiate a Guzzle HTTP client object
  *
  * @return Client
  */
 public function getClient()
 {
     if (is_null($this->client)) {
         $this->client = new Client(sprintf('%s://%s', Config::GRAPH_USE_SSL === true ? 'https' : 'http', Config::GRAPH_BASE_URL));
         $this->client->setConfig(array('exceptions' => true));
     }
     return $this->client;
 }
开发者ID:chrisnoden,项目名称:facebook-utils,代码行数:13,代码来源:GraphRequest.php

示例8: setTimeout

 /**
  * {@inheritdoc}
  */
 public function setTimeout($timeout)
 {
     $guzzleConfig = array(Client::CURL_OPTIONS => array(CURLOPT_TIMEOUT => $timeout, CURLOPT_CONNECTTIMEOUT => $timeout));
     $this->client->setConfig($guzzleConfig);
 }
开发者ID:cultuurnet,项目名称:culturefeed-http-guzzle,代码行数:8,代码来源:HttpClient.php

示例9: __construct

 /**
  *
  */
 public function __construct()
 {
     $this->guzzleClient = new Guzzle\Http\Client(static::$baseUrl);
     $this->guzzleClient->setConfig(array('defaults' => array('headers' => array('Content-Type' => 'application/json', 'Authorization' => sprintf('Bearer %s', $this->accessToken)))));
 }
开发者ID:MusicalAPP,项目名称:spotify-web-api,代码行数:8,代码来源:API.php


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