本文整理汇总了PHP中GuzzleHttp\Client::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::__construct方法的具体用法?PHP Client::__construct怎么用?PHP Client::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\Client
的用法示例。
在下文中一共展示了Client::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor.
*
* @param string $xApiKey
* An api.data.gov api key that is granted to your user.
*
* @param string $xAdminAuthToken
* Admin Authorization Token provided by api.data.gov admin accounts.
*/
public function __construct($xApiKey, $xAdminAuthToken)
{
parent::__construct(['base_url' => $this->apiUrl]);
$this->xApiKey = $xApiKey;
$this->xAdminAuthToken = $xAdminAuthToken;
$this->setDefaultOption('headers', array('X-Api-Key' => $this->xApiKey, 'X-Admin-Auth-Token' => $this->xAdminAuthToken, 'Content-Type' => 'application/json', 'Accept' => 'text/*'));
}
示例2: __construct
/**
* Client constructor.
*/
public function __construct(array $config = [])
{
$vindi = new Vindi();
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
$config = array_merge(['base_uri' => Vindi::$apiBase, 'auth' => [$vindi->getApiKey(), '', 'BASIC'], 'headers' => ['Content-Type' => 'application/json', 'User-Agent' => trim('Vindi-PHP/' . Vindi::$sdkVersion . "; {$host}")], 'verify' => $vindi->getCertPath(), 'timeout' => 60, 'curl.options' => ['CURLOPT_SSLVERSION' => 'CURL_SSLVERSION_TLSv1_2']], $config);
parent::__construct($config);
}
示例3: __construct
public function __construct($base_uri, $username, $access_token)
{
parent::__construct(['base_uri' => $base_uri]);
$this->access_token = $access_token;
$this->username = $username;
$this->auth = new Authentication($this);
}
示例4: __construct
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->token = true;
$this->ph_session = (new \Phalcon\DI())->getDefault()->getSession();
$this->base_url = getenv('API_URL');
}
示例5: __construct
/**
* Constructor
*
* @param string $version version number (v0)
*/
public function __construct($version = null)
{
if ($version) {
$this->version = $version;
}
parent::__construct(['base_url' => implode("/", [self::API_BASE_URL, $this->version, ''])]);
}
示例6: __construct
/**
* @param Endpunkt $endpoint API-Endpunkt
* @param string $userAgent User-Agent
* @param string $token API-Token
* @param string $user Benutzername
* @param string $password Passwort
* @param bool $compress Komprimierung aktivieren
* @param bool $verify SSL-Zertifikate verifizieren
*/
public function __construct(Endpunkt $endpoint, $userAgent, $token, $user, $password, $compress = false, $verify = true)
{
parent::__construct(['base_url' => $endpoint->getBaseUrl()]);
if (!$userAgent) {
throw new \InvalidArgumentException('User-Agent erforderlich.');
}
if (!$token) {
throw new \InvalidArgumentException('Token erforderlich.');
}
if (!$user) {
throw new \InvalidArgumentException('Benutzername erforderlich.');
}
if (!$password) {
throw new \InvalidArgumentException('Passwort erforderlich.');
}
$headers = ['User-Agent' => sprintf('%1$s; Token=%2$s', $userAgent, $token)];
if ($compress) {
$headers['Accept-Encoding'] = 'gzip';
}
$this->setDefaultOption('headers', $headers);
$this->setDefaultOption('auth', [$user, $password]);
$this->setDefaultOption('verify', $verify);
if ($compress) {
$this->setDefaultOption('decode_content', true);
} else {
$this->setDefaultOption('decode_content', false);
}
$this->endpoint = $endpoint;
}
示例7: __construct
/**
* Sets up our client vars and initialises the base_uri on the
* GuzzleHttp Client instance.
*
* @param string $key Google Places API key
* @param array $location Latitude/Longitude pair
* @param array $options Options for refining the search.
*/
public function __construct($key, array $location, $options = [])
{
$this->key = $key;
$this->location = $location;
$this->options = $options;
parent::__construct(['base_uri' => $this->endpoint]);
}
示例8: __construct
/**
* @param string $apiKey The API key for your ThisData account
* @param int $version The version of the ThisData API to use
* @param array $options Extra options for the GuzzleClient
*/
public function __construct($apiKey, $version = 1, array $options = [])
{
$this->apiKey = $apiKey;
$this->version = $version;
$options = array_merge($this->getDefaultConfiguration(), $options);
parent::__construct($options);
}
示例9: __construct
/**
* @param array $accessToken
* @param string $version
* @param array $config
*/
public function __construct($accessToken, $version = 'v2.6', array $config = [])
{
$this->accessToken = $accessToken;
$this->version = $version;
$config = array_merge(['base_uri' => $this->baseUri, 'query' => ['access_token' => $this->accessToken]], $config);
parent::__construct($config);
}
示例10: __construct
/**
* @param Client $client
*/
public function __construct(Client $client)
{
$this->client = $client;
$this->testing = $this->client->isTesting();
$this->options = array('query' => array('lang' => $this->client->getLocale()));
parent::__construct(array('base_url' => array($this->client->getUrl() . '/{version}/', array('version' => $this->client->getVersion()))));
}
示例11: __construct
/**
* @param AccessTokenInterface $token
* @param array $options
*/
public function __construct(AccessTokenInterface $token, array $options = [])
{
$options = array_merge($options, ['emitter' => EventsManager::getEmitter()]);
parent::__construct($options);
if ($token instanceof OAuth2AccessTokenInterface) {
$this->getEmitter()->on('before', function (BeforeEvent $event) use($token) {
/** @var \Eva\EvaOAuth\OAuth2\Token\AccessToken $token */
$event->getRequest()->setHeader('Authorization', $token->getTokenType() . ' ' . $token->getTokenValue());
});
} else {
$signatureMethod = isset($options['signature_method']) ? $options['signature_method'] : SignatureInterface::METHOD_HMAC_SHA1;
$signatureClasses = [SignatureInterface::METHOD_PLAINTEXT => 'Eva\\EvaOAuth\\OAuth1\\Signature\\PlainText', SignatureInterface::METHOD_HMAC_SHA1 => 'Eva\\EvaOAuth\\OAuth1\\Signature\\Hmac', SignatureInterface::METHOD_RSA_SHA1 => 'Eva\\EvaOAuth\\OAuth1\\Signature\\Rsa'];
if (false === isset($signatureClasses[$signatureMethod])) {
throw new InvalidArgumentException(sprintf('Signature method %s not able to process', $signatureMethod));
}
$signatureClass = $signatureClasses[$signatureMethod];
$this->getEmitter()->on('before', function (BeforeEvent $event) use($token, $signatureClass) {
/** @var Request $request */
$request = $event->getRequest();
/** @var \Eva\EvaOAuth\OAuth1\Token\AccessToken $token */
$httpMethod = strtoupper($request->getMethod());
$url = Url::fromString($request->getUrl());
$parameters = ['oauth_consumer_key' => $token->getConsumerKey(), 'oauth_signature_method' => SignatureInterface::METHOD_HMAC_SHA1, 'oauth_timestamp' => (string) time(), 'oauth_nonce' => strtolower(Text::generateRandomString(32)), 'oauth_token' => $token->getTokenValue(), 'oauth_version' => '1.0'];
$signature = (string) new $signatureClass($token->getConsumerSecret(), Text::buildBaseString($httpMethod, $url, $parameters), $token->getTokenSecret());
$parameters['oauth_signature'] = $signature;
$event->getRequest()->setHeader('Authorization', Text::buildHeaderString($parameters));
});
}
}
示例12: __construct
/**
* @param KeyValueStore $kvs
* @param string $clientId
* @param string $clientSecret
* @param string $redirectUri
*/
public function __construct(KeyValueStore $kvs, $clientId, $clientSecret, $redirectUri)
{
$this->kvs = $kvs;
$this->clientId = $clientId;
$this->clientSecret = $clientSecret;
$this->redirectUri = $redirectUri;
parent::__construct();
}
示例13: __construct
/**
* GuzzleWrapper constructor.
* @param $client
*/
public function __construct(array $config)
{
$config['on_stats'] = function (TransferStats $stats) {
// contient les stats
$stats->getHandlerStats();
};
parent::__construct($config);
}
示例14: __construct
public function __construct($parameters)
{
parent::__construct();
$this->url = $parameters['url'];
$this->version = $parameters['version'];
$this->id = $parameters['id'];
$this->sslVerficationEnabled = $parameters['sslVerifcationEnabled'];
}
示例15: __construct
/**
* Client constructor.
* @param array $config
*/
public function __construct($config = [])
{
$config = new Config($config);
if (!$config->hasRequired()) {
throw new NotExistRequiredException();
}
parent::__construct($config->toGuzzleConfig());
}