如何从POST内部发送另一个POST


How send another POST from inside a POST

我正试图发送POST,但在我的另一个脚本上收到了一个空帖子。我做错了什么?

if(isset($_POST)){
    $url = 'http://localhost:3000/post';
    $data = $_POST;
    $options = array(
        'http' => array(
            'header'  => "Content-type: application/x-www-form-urlencoded'r'n",
            'method'  => 'POST',
            'content' => http_build_query($data),
        ),
    );
    $context  = stream_context_create($options);
    $result = file_get_contents($url, false, $context);
}

这是用于2个应用程序之间的同步。当我更换时

$data=$_POST;

通过

$data = array('key1' => 'value1', 'key2' => 'value2');

工作起来很有魅力!

谢谢!

问题是wordpress在某个时候删除了$_POST,在我将代码移到文件顶部后,问题得到了解决。谢谢大家!