The delete
method takes two parameters, the service URL and request parameters to be used with delete request to the service.
As in the case of GET
requests, we use the request parameters and build the URL with the request parameters in place.
$params_str = "?"; if (is_array($params)) { foreach ($params as $key => $value) { $params_str .= urlencode($key) . "=" . urlencode($value) . "&"; } } else { $params_str .= $params; } $url .= $params_str;
Then if CURL is present, we send the DELETE
request to the service URL with CURL.
if ($this->with_curl) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "delete");
curl_setopt($curl, CURLOPT_USERAGENT, RESTClient :: USER_AGENT);
$result = curl_exec($curl);
curl_close($curl);
}
If CURL is not present, we use the fopen
logic.