本文整理汇总了PHP中GuzzleHttp\ClientInterface::getDefaultOption方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientInterface::getDefaultOption方法的具体用法?PHP ClientInterface::getDefaultOption怎么用?PHP ClientInterface::getDefaultOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\ClientInterface
的用法示例。
在下文中一共展示了ClientInterface::getDefaultOption方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareClient
/**
* @param ClientInterface $client
* @param string $apiKey
*
* @return HTTPClient
*/
private function prepareClient(ClientInterface $client, $apiKey)
{
if ($client->getDefaultOption('timeout') === null) {
$client->setDefaultOption('timeout', 5.0);
}
$client->setDefaultOption('headers/X-Api-Key', $apiKey);
return $client;
}
示例2: isLoggedIn
public function isLoggedIn(ClientInterface $guzzle)
{
if (($cookieJar = $guzzle->getDefaultOption('cookies')) instanceof CookieJar) {
/** @var \GuzzleHttp\Cookie\SetCookie $cookie */
foreach ($cookieJar as $cookie) {
// check required cookies
if ($cookie->getDomain() == $this->siteConfig->getHost()) {
return true;
}
}
}
return false;
}
示例3: CookieJar
function it_posts_a_login_request(ClientInterface $guzzle)
{
$guzzle->post('http://example.com/login', ['body' => ['username' => 'johndoe', 'password' => 'unkn0wn', 'action' => 'login', 'foo' => 'bar'], 'verify' => false, 'allow_redirects' => true])->shouldBeCalled();
$guzzle->getDefaultOption('cookies')->willReturn(new CookieJar(false, new SetCookie()));
$this->login($guzzle);
}
示例4: createAuthHttp
private function createAuthHttp(ClientInterface $http)
{
return new Client(['base_url' => $http->getBaseUrl(), 'defaults' => ['exceptions' => true, 'verify' => $http->getDefaultOption('verify'), 'proxy' => $http->getDefaultOption('proxy')]]);
}