PHP将json结果发布到自定义URL

时间:2015-12-15 21:28:48

标签: php json

默认情况下,我的网络服务我必须向自定义用户的网址发帖。我可以发布数组,但我想将请求作为json有效负载发布,下面的代码可能是post数据,但我无法从PHP获取数据。

android.util.Log.i("sometag", String.format(...))

此代码的结果是:

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;
}

<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

发布数据后我得到空数组

1 个答案:

答案 0 :(得分:0)

包括<input type = "hidden"在内的所有输入都需要一个名称,因此name = "something"