我正在开发一个php数据接口。但我无法获取数据。
A.php
$options = [
'http' => [
'method' => 'POST',
'content' => $data,
'header' => "Content-Type: application/json\r\n" .
"Accept: application/json\r\n"
]
];
$context = stream_context_create( $options );
$result = file_get_contents('B.php', false, $context );
echo $result; //Output: I have recvieve it. // It's proves that the url is right.
B.php
$data = $_POST; // The $data is empty. Why??? It can't get the data
echo 'I have recvieve it';