我正在尝试向 Oauth 的 API 发送响应。遗憾的是,Symfony2 文档在解释 $response->headers->set(...);
的所有不同部分方面做得很差。
这是我的 OauthController 中的响应部分:
$response = new Response();
$response->setStatusCode(200);
$response->headers->set('Location', 'url=' . $auth_url);
return $response->send();
Controller 必须有一个 return
语句,所以我的代码看起来不错,或者我如何从普通 php 复制 header('Location: ' . $auth_url);
?
谢谢!
最佳答案
既然要做重定向,那么可以用RedirectResponse
而不是常规的 Response
:
return new RedirectResponse($auth_url);
关于php - Symfony2 响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35000705/