我一直在寻找大约2个小时,我无法弄明白如何阅读最终的回应uri.
在先前版本的PHP Guzzle中,您只需致电即可$response->getEffectiveUrl()获得它.
我期望在新版本中有类似的东西,所以最终代码如下所示:
$response = $httpClient->post('http://service.com/login', [
'form_params' => [
'user' => $user,
'padss' => $pass,
]
]);
$url = $response->getEffectiveUrl();
Run Code Online (Sandbox Code Playgroud)
但是在最新版本$response中现在是一个GuzzleHttp\Psr7\Response并且没有方法可以让我检索uri.
我在这里阅读了重定向(http://guzzle.readthedocs.org/en/latest/quickstart.html#redirects),但它没有说明
谢谢@YauheniPrakopchyk