I have just upgraded from guzzle 3 to guzzle 6
Now i have some code here..
$request = $this->_client->get($url);
$response = $request->send();
$url = $response->getInfo('url');
return $url;
After updating to guzzle 6 I see that getInfo() & also geteffectiveurl() has been removed.. for some reason. so my new code is...
$res = $this->_client->request('GET', $url, ['on_stats' => function (TransferStats $stats) use (&$url) {
$url = $stats->getEffectiveUri();
}])->getBody()->getContents();
return $url;
Now that $url variable is a GuzzleHttp\Psr7\Uri Object which doesnt really solve my problem as i just need to return the url as a string.
How can i covert the object ->
[24-Mar-2017 19:12:26 UTC] GuzzleHttp\Psr7\Uri Object
(
[scheme:GuzzleHttp\Psr7\Uri:private] => https
[userInfo:GuzzleHttp\Psr7\Uri:private] =>
[host:GuzzleHttp\Psr7\Uri:private] => signup.testapp.com
[port:GuzzleHttp\Psr7\Uri:private] =>
[path:GuzzleHttp\Psr7\Uri:private] => /login
[query:GuzzleHttp\Psr7\Uri:private] => username=jeff&blablablablabla
[fragment:GuzzleHttp\Psr7\Uri:private] =>
)
Into a simple string that i can pass on to make another request to?
Or am i missing somthing? getInfo('url') in Guzzle 3 was the perfect solution to a problem surely another one has taken its place?
Thanks