如何将当前页面重定向到带有 guzzle (laravel) 的帖子响应



例如,我有一个表单:

<form method='post' action='https://test.com'>
<input name='name' value='test'>
<button name='test' type='submit'> </button>
</form>

提交后,这会将我重定向到另一个页面。 我的问题是'我怎样才能用控制器的 guzzle 做同样的事情?我试图制作:

$client =         $client = new GuzzleHttpClient();
$response = $client->post('https://test.com', 
form_params => [
'name' => 'test'
]);
return $response->getBody()->read(1024);

在这里,我得到了我想要的回应。 但我想将我的当前页面重定向到带有响应的页面。

在方法控制器中使用return redirect()->back()

你必须尝试这样的事情

$client = $client = new GuzzleHttpClient();
$response = $client->post('https://test.com', 
form_params => [
'name' => 'test'
]);
$response_to_return = $response->getBody()->read(1024);
return redirect()->back()->withInput()->with('response_to_return', $response_to_return);