Reputation: 41
I am trying to set the http method of Curl to PUT but my code is not working
$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);
The above code is what I have written but it is not setting it to PUT method Please help
Upvotes: 0
Views: 743
Reputation: 82755
Try changing
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
to
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
Upvotes: 1