I\'m trying to communicate with a web service who\'s waiting first a token in each request.
There is my problem, the web service is waiting the token throught file_get
PUT
method is generally used to update resource.GET
) resource information. PUT
request to server.In php, curl is used for making rest calls. HTTP GET
and POST
are directly supported in curl. But for PUT and DELETE you have to set options accordingly in curl_setopt()
$curl = curl_init($url);
**curl_setopt($curl,CURLOPT_CUSTOMREQUEST,"PUT")**;
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_HTTPHEADER,$headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl,CURLOPT_POSTFIELDS,$update_para);
$curl_response = curl_exec($curl);
curl_setopt($ch, CURLOPT_PUT, true);
For more info you can refer: How to start a GET/POST/PUT/DELETE request and judge request type in PHP?