Hi I have code PHP and I want to convert this code into symfony controller
Code PHP
header("Pragma: no-cache");
header("Cache-Control: private");
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0", false);
header("Expires: 0");
echo "<html>";
echo "<body>";
echo "<form action=\"" . $url . "\" method=\"post\" name=\"form\" id=\"form\">";
echo "<input type=\"hidden\" name=\"key1\" value=\"" . $code . "\">";
echo "<input type=\"hidden\" name=\"key2\" value=\"$value\">";
echo ("</form>");
echo "<script language=\"JavaScript\">";
echo "document.form.submit();";
echo "</script>";
echo "</body>";
echo "</html>";
This code must redirect to another web site with the parametres posted is for authentification
this s my controller
class RedirectController extends Controller
{
/**
* @Route("/redirect", name="redirect_root")
*/
public function redirectAction(Request $request)
{
$data = array(
'key1' => $code,
'key2' => $value,
);
$url = 'http://login.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
I use the response of HttpFoundation but alway The params dons't passed to login