By default on my web service I must make a post request to custom user's url. I can post the array but I would like to post request as a json payload, the code below could be the post data, but I cannot get the data from PHP.
function redirect_to_customer($result = [], $redirect_url = "")
{
$html = '<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body onload="closethisasap();">
<form name="redirectpost" method="POST" action="' . $redirect_url . '">
';
if (!is_null($result)) {
$result = json_encode($result);
$html .= '<input type="hidden" value="' . str_replace('"', "'", $result) . '"> ';
}
$html .= "
</form>
</body>
<script type=\"text/javascript\">
function closethisasap() {
document.forms[\"redirectpost\"].submit();
}
</script>
</html>";
echo $html;
}
result of this code is :
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
</head>
<body onload = "closethisasap();">
<form name = "redirectpost" method = "POST" action = "http://www.sample.com/response.php">
<input type = "hidden" value = "{'code':'-103','message':'order_id must be unique'}">
</form>
</body>
<script type = "text/javascript">
function closethisasap()
{
document . forms["redirectpost"] . submit();
}
</script>
</html>
response.php
user's file content :
<?php
print_r($_POST);
?>
after post data i get empty array