本文整理匯總了PHP中GuzzleHttp\Psr7\Uri::withScheme方法的典型用法代碼示例。如果您正苦於以下問題:PHP Uri::withScheme方法的具體用法?PHP Uri::withScheme怎麽用?PHP Uri::withScheme使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GuzzleHttp\Psr7\Uri
的用法示例。
在下文中一共展示了Uri::withScheme方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: perform
/**
* {@inheritdoc}
*/
public function perform(OperationInterface $operation, ConfigurationInterface $configuration)
{
$preparedRequestParams = $this->prepareRequestParams($operation, $configuration);
$queryString = $this->buildQueryString($preparedRequestParams, $configuration);
$uri = new Uri(sprintf($this->requestTemplate, $configuration->getCountry(), $queryString));
$request = new \GuzzleHttp\Psr7\Request('GET', $uri->withScheme($this->scheme), ['User-Agent' => 'ApaiIO [' . ApaiIO::VERSION . ']']);
$result = $this->client->send($request);
return $result->getBody()->getContents();
}
示例2: executeKohanaRequest
private function executeKohanaRequest(ServerRequestInterface $request, $redirect = 0)
{
if ($redirect >= self::MAX_REDIRECTS) {
throw new LogicException(sprintf('Maximum Number of redirects (%s) for url %s', self::MAX_REDIRECTS, $request->getUri()));
}
Request::$initial = $kohanaRequest = $this->getKohanaRequest($request);
Request::$user_agent = self::USER_AGENT;
$_FILES = $request->getAttribute('FILES');
$kohanaResponse = $kohanaRequest->execute();
$this->current = $request;
$status = $kohanaResponse->status();
if ($status >= 300 && $status < 400) {
$redirectUri = new Psr7\Uri($kohanaResponse->headers('location'));
$localUri = $redirectUri->withScheme(null)->withUserInfo(null)->withHost(null)->withPort(null);
return $this->executeKohanaRequest(new Psr7\ServerRequest('GET', $localUri), $redirect + 1);
}
return $kohanaResponse;
}