使用PHP捕获curl-d发送的数据

使用PHP捕获curl-d发送的数据,php,curl,capture,Php,Curl,Capture,我试图用PHP捕获curl发送的数据,但它没有出现在我的终端上 我正在通过控制台执行: curl -d "tests_123" "http://www.example.com/capture.php" 我在capture.php中有 print_r($_POST); print_r($_GET); print_r($_REQUEST); 但什么也没有出现 我做错什么了吗?您必须使用此功能来捕获此类数据: $log.="http_get_request_body \n"; $entityBod

我试图用PHP捕获curl发送的数据,但它没有出现在我的终端上

我正在通过控制台执行:

curl -d "tests_123" "http://www.example.com/capture.php"
我在capture.php中有

print_r($_POST);
print_r($_GET);
print_r($_REQUEST);
但什么也没有出现


我做错什么了吗?

您必须使用此功能来捕获此类数据:

$log.="http_get_request_body \n";
$entityBody = file_get_contents('php://input');
$log.=print_r($entityBody,true);
$log.="\n----------------\n\n";

感谢@crodas的帮助!:)

我确信您可以使用
$response=file\u get\u contents('php://input');

但是,如果稍微更改一下命令,并为要发送的值添加一个键,就可以很容易地从$\u POST变量中获取数据

curl -d "Mykey=tests_123" "http://www.example.com/capture.php"

print_r($_POST);
// array ( Mykey => test_123)
完全回答