本文整理汇总了PHP中GuzzleHttp\ClientInterface::getConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientInterface::getConfig方法的具体用法?PHP ClientInterface::getConfig怎么用?PHP ClientInterface::getConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\ClientInterface
的用法示例。
在下文中一共展示了ClientInterface::getConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param GuzzleClientInterface $client
* @param RequestBuilder $requestBuilder
*
* @throws \InvalidArgumentException
*/
public function __construct(GuzzleClientInterface $client, RequestBuilder $requestBuilder)
{
if ($client->getConfig('base_url') !== $requestBuilder->getBaseUrl()) {
throw new \InvalidArgumentException(sprintf('Expected base url of client and request build to match. Got respectively "%s" and "%s" instead.', $client->getConfig('base_url'), $requestBuilder->getBaseUrl()));
}
$this->client = $client;
$this->requestBuilder = $requestBuilder;
}
示例2: __invoke
public function __invoke($mmId)
{
$config = $this->httpClient->getConfig();
$baseUri = $config['base_uri'];
$auth = $config['auth'];
$url = $baseUri->withQueryValue($baseUri, 'mm_id', $mmId);
$response = $this->httpClient->request('GET', $url, ['auth' => $auth]);
$responseData = json_decode($response->getBody()->getContents(), true);
if (!isset($responseData['data']) || empty($responseData['data'])) {
return;
}
return $responseData['data'][0];
}
示例3: createRequest
/**
* @param string $method
* @param array $options
*
* @return RequestInterface
*/
protected function createRequest($method, $options)
{
$uri = $this->httpClient->getConfig('base_uri');
$defaults = $this->httpClient->getConfig('defaults');
$headers = isset($defaults['headers']) ? $defaults['headers'] : [];
return $this->messageFactory->createRequest($method, $uri, $headers, $options);
}
示例4: __construct
/**
* @param ClientInterface $client
*/
public function __construct(ClientInterface $client, TimelineToken $token)
{
$this->baseUri = $client->getConfig('base_uri');
if ($this->baseUri === null) {
$this->baseUri = 'https://timeline-api.getpebble.com';
}
$this->token = $token;
$this->client = $client;
}
示例5: authenticate
/**
* @inheritDoc
*/
public function authenticate(ClientInterface $httpClient)
{
if (!$httpClient->getConfig('cookies') instanceof CookieJarInterface) {
throw new UnsupportedClientException('This HTTP client does not have cookies configured');
}
$homePageDom = $this->requestHomePageDom($httpClient);
if (!$this->isLoggedIn($homePageDom)) {
if ($homePageDom->query('#_login-form')->count() < 1) {
throw new LoginFormNotFoundException();
}
$csrfToken = $homePageDom->query('#_login-form [name=fs_csrf]')->val();
$newHomePageDom = $this->doLogin($httpClient, $csrfToken);
if (!$this->isLoggedIn($newHomePageDom)) {
throw new FailedLoggingInException('User was not logged in');
}
}
}
示例6: get
/**
* {@inheritdoc}
*/
public function get($url, array $args = [])
{
$options = [];
// Add additional arguments to the defaults:
// Guzzle 6 does no longer merge the default query params with the
// additional params given here!
if (!empty($args)) {
if ($this->guzzleVersion > 5) {
$options['query'] = array_merge($this->client->getConfig('query'), $args);
} else {
$options['query'] = $args;
}
}
try {
$this->response = $this->client->get($url, $options);
} catch (RequestException $e) {
$this->response = $e->getResponse();
return $this->handleError();
}
// $response->json() is not compatible with Guzzle 6.
return json_decode($this->response->getBody(), true);
}
示例7: getUrl
/**
* Get the URL.
*
* @return \GuzzleHttp\Psr7\Uri
*/
public function getUrl()
{
return $this->client->getConfig('base_uri');
}
示例8: createAuthHttp
private function createAuthHttp(ClientInterface $http)
{
return new Client(['base_uri' => $http->getConfig('base_uri'), 'exceptions' => true, 'verify' => $http->getConfig('verify'), 'proxy' => $http->getConfig('proxy')]);
}
示例9: getRequestKey
/**
* @param string $url
* @param array $options
*
* @return string
*/
protected function getRequestKey($url, array $options)
{
$options = array_replace_recursive(['headers' => $this->client->getConfig('headers'), 'query' => $this->client->getConfig('query')], $options);
return hash_hmac('md5', $url, serialize($options));
}
示例10: getHttpBaseUrl
/**
* @return \GuzzleHttp\Psr7\Uri
*/
protected function getHttpBaseUrl()
{
return $this->client->getConfig('base_uri');
}
示例11: createRequest
private function createRequest($uri)
{
$baseUri = \GuzzleHttp\Psr7\uri_for($this->client->getConfig('base_uri'));
$uri = Uri::resolve($baseUri, $uri);
return new Request('GET', $uri);
}
示例12: getFinalPath
/**
* @param string $path
*
* @return string
*/
protected function getFinalPath($path)
{
return $this->client->getConfig('base_uri')->getPath() . '/' . $path;
}
示例13: getTokenEndpoint
/**
* @return string
*/
private function getTokenEndpoint()
{
return vsprintf('%s%s', [$this->httpClient->getConfig('base_uri'), $this->serverConfig->getParams()['token_endpoint']]);
}
示例14: createBaseUri
/**
* Creates the uri with the unit query parameter
*
* @param mixed $unit
* @return UriInterface
*/
private function createBaseUri($unit)
{
$config = $this->httpClient->getConfig();
$baseUri = $config['base_uri'];
return $baseUri->withQueryValue($baseUri, 'unit', $unit);
}
示例15: getBaseUri
/**
* @return UriInterface
*/
public function getBaseUri()
{
return new Uri($this->client->getConfig('token_pool')->getPublicUrl());
}