Yii2如何将表单请求发送到外部url [英] Yii2 how to send form request to external url
问题描述
如何向外部网址发送重定向帖子请求?我在控制器中的代码:
if ($model->load(Yii::$app->request->post()) && $model->validate()) {//发送post请求到外部链接}
您需要使用 307
状态代码,用于指定应该使用相同 POST 数据执行的重定向.
$this->redirect('https://example.com', 307);
<块引用>
HTTP 307 Temporary Redirect
重定向状态响应代码表示请求的资源已临时移动到 Location
标头给出的 URL.
重用原始请求的方法和正文来执行重定向的请求.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307
How to send a redirect post request to external url? my code in controller:
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
// send post request to external link
}
You need to use 307
status code to specify redirection which should be performed with the same POST data.
$this->redirect('https://example.com', 307);
The
HTTP 307 Temporary Redirect
redirect status response code indicates that the resource requested has been temporarily moved to the URL given by theLocation
headers.The method and the body of the original request are reused to perform the redirected request.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307
这篇关于Yii2如何将表单请求发送到外部url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!