0
我想發送一個POST,但我在我的其他腳本上得到空的帖子。 我做錯了什麼?如何從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');
就像一個魅力!
謝謝!
你會得到什麼結果?任何錯誤消息或其他輸出? – 2014-10-31 18:51:26
沒有錯誤。只是收到一個空的帖子。 – 2014-10-31 18:52:00
您可以嘗試使用更小的'data'集合來測試第二個POST,可能只是一對名稱/值對。確保首先工作。 – 2014-10-31 18:57:27