【发布时间】:2021-11-18 08:24:28
【问题描述】:
发布
在我的本地机器上,我想像这样使用 cURL 作为 HTTP 客户端:
curl -X POST -F 'email=derp@example.com' -F 'password=blink182' http://example.com
上面的 curl 语句使用了 HTTP POST 方法,可以像这样在 PHP 中检索:
echo $_POST['email']; // derp@example.com
echo $_POST['password']; // blink182
php://输入
但是,我真正想要的是来自 PHP input stream php:://input 而不是来自 POST method $_POST 的数据。
可以像这样在 PHP 中检索 PHP 输入流:
$input = json_decode( file_get_contents( 'php://input' ) );
echo $input->email; // derp@example.com
echo $input->password; // blink182
这让我想到了我的问题,如何使用 curl 发送 PHP 输入流数据?
【问题讨论】:
标签: php curl command-line-interface