本文整理匯總了PHP中GuzzleHttp\Message\ResponseInterface::getEffectiveUrl方法的典型用法代碼示例。如果您正苦於以下問題:PHP ResponseInterface::getEffectiveUrl方法的具體用法?PHP ResponseInterface::getEffectiveUrl怎麽用?PHP ResponseInterface::getEffectiveUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GuzzleHttp\Message\ResponseInterface
的用法示例。
在下文中一共展示了ResponseInterface::getEffectiveUrl方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: verifyIfTokenNeedsRefreshing
protected function verifyIfTokenNeedsRefreshing(ResponseInterface $response, $action, $vars = [])
{
if ($response->getStatusCode() != 401) {
return $response;
}
if ($this->tokenChecked) {
throw new Exception(sprintf('Response could not be obtained due to invalid token and response. Please check your credentials and action: %s', $response->getEffectiveUrl()));
}
$this->tokenChecked = true;
if (file_exists($this->tokenLocation())) {
unlink($this->tokenLocation());
}
return $this->get($action, $vars);
}
示例2: validateResponse
/**
* Check if request was successful
* @param \GuzzleHttp\Message\ResponseInterface $response
* @throws \UnexpectedValueException
*/
protected function validateResponse($response)
{
if ($response->getStatusCode() !== 200) {
throw new \UnexpectedValueException('Failed to download ' . $response->getEffectiveUrl() . '. Server responded with ' . $response->getStatusCode() . ' instead of 200.');
}
}
示例3: effectiveUrl
/**
* Get the effective URL that resulted in this response (e.g. the last
* redirect URL).
*
* @return string
*/
public function effectiveUrl()
{
return $this->response->getEffectiveUrl();
}