将DELETE请求发送到外部API

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&parameter2=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...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);