将DELETE请求发送到外部API

时间:2014-10-21 10:33:07

标签: php symfony

我必须向外部缓存API发送DELETE请求。我怎样才能做到这一点?我一直在考虑使用file()函数,例如:

file('https://someurl.com/api?parameter1=foo&parameter2=bar');

但首先它不能识别响应的类型,其次它会抛出错误:

Failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in ...它似乎将&符号转换为&(至少xdebug显示的那样)。

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

使用cURL:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
$result = curl_exec($ch);
相关问题