我正在尝试将Curl的http方法设置为PUT但我的代码无法正常工作
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:
application/json','Content-Length: ' . strlen($post)));
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
上面的代码是我写的,但没有将它设置为PUT方法 请帮忙
答案 0 :(得分:1)
尝试更改
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
到
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');