在codeigniter应用程序中发送HTTP DELETE请求?

时间:2017-06-14 08:16:18

标签: php web-services curl delete-method

任何人都可以让我知道如何使用http删除方法。我试图使用curl实现这一点,但它给出了我不明白的http代码0。任何人都可以告诉我还有什么需要添加到下面的代码

$url = 'https://api.rezdy.com/v1/bookings/R1Z8HKV/?apiKey=f125ad643aff4cbe98043302424a###';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
$api_response = curl_exec($ch); 
$api_response_info = curl_getinfo($ch); 
curl_close($ch);
$api_response_header = trim(substr($api_response, 0, $api_response_info['header_size']));
$api_response_body = substr($api_response, $api_response_info['header_size']);
echo $api_response_info['http_code'];
echo "<br><br>";
echo $api_response_header;
echo "<br><br>";
echo $api_response_body;
echo "<br><br>";

0 个答案:

没有答案