0
我有一个curl请求,它应该向我的web服务器上的PHP文件发送一个PUT请求。当我收到这个请求时,我想列出使用此PUT请求收到的所有POST数据,但是没有收到POST数据。请你能告诉我哪里出错了吗?在cURL的另一端没有收到POST数据请求
$ch = curl_init();
$fields = array(
'username' => 'username'
);
curl_setopt($ch, CURLOPT_URL, "http://localhost/linetime/user/1");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
var_dump($result);
为了方便访问输入流,还可以使用'$ input = file_get_contents(“php:// input”);'。 – Repox