本文整理汇总了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();
}