【发布时间】:2020-11-27 17:17:12
【问题描述】:
我需要从GuzzleHTTP 的Response 中获取URI,目前正在使用getAsync,并同时处理至少50 个项目,需要一种方法来获取URI我从大嘴里使用Client。
$groups->each(function($group) {
$promises = $group->map( function($lead, $index) {
$client = new Client(['http_errors' => false]);
return $client->getAsync($lead->website, [
'timeout' => 5, // Response timeout
'connect_timeout' => 5, // Connection timeout
]);
})->toArray();
settle($promises)->then( function($results) {
$collections = collect($results);
$fulfilled = $collections->where('state', 'fulfilled')->all();
})->wait();
});
似乎Request 有这个getUri 方法,但Response 没有也无法在接口或类和文档中找到。希望有人能提供帮助
编辑:尝试getEffectiveUrl,但这仅适用于 Guzzle 5,目前使用 6
【问题讨论】: