本文整理汇总了PHP中Guzzle\Http\ClientInterface::getDefaultOption方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientInterface::getDefaultOption方法的具体用法?PHP ClientInterface::getDefaultOption怎么用?PHP ClientInterface::getDefaultOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\ClientInterface
的用法示例。
在下文中一共展示了ClientInterface::getDefaultOption方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* {@inheritdoc}
*/
public function load(ClassMetadata $metadata, ParserInterface $parser, $retries = 0)
{
try {
// Send the request and get the response.
$response = $this->client->get('files/' . $this->folder . '/children')->send();
} catch (ClientErrorResponseException $e) {
if ($this->client->getDefaultOption('request.options/headers/Authorization') && $retries < 1) {
$this->refreshToken();
$retries++;
return $this->load($metadata, $parser, $retries);
}
$this->handleBadResponseExceptions($e);
}
$json = $response->json();
$files = $json['items'];
$batch = array();
foreach ($files as $file) {
$batch[] = $this->client->get('files/' . $file['id']);
}
try {
$responses = $this->client->send($batch);
} catch (MultiTransferException $e) {
$this->handleBadResponseExceptions($e->getFirst());
}
$content = array();
foreach ($responses as $response) {
$file = $response->json();
$response = $this->client->get($file['downloadUrl'])->send();
$downloadedContent = $response->getBody(true);
$content[] = $parser->parse($metadata, $file['originalFilename'], $downloadedContent);
}
return $content;
}