I have to send a DELETE request to the external cache API. How can I do that? I've been thinking about using file()
function, like:
file('https://someurl.com/api?parameter1=foo¶meter2=bar');
But first of all it doesn't recognize the type of the response, and second it throws an error:
Failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in
Failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in
...And it seems to convert ampersands into &
(at least that's what xdebug shows).
How can I solve this?
Use cURL for that:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
$result = curl_exec($ch);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.