curl php
curl如何發起DELETE/PUT請求DELETE:curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
PUT:curl_setopt($ch, CURLOPT_PUT, true);
GET:curl_setopt($ch, CURLOPT_HTTPGET, true);
POST:curl_setopt($ch, CURLOPT_POST, true);
可以通過$_SERVER['REQUEST_METHOD']獲得請求類型,PUT/DELETE的參數可以這樣獲取:parse_str(file_get_contents('php://input'), $request_vars);注意:parsestr(filegetcontents('php://input'), $requestvars); 只能取application/x-www-form-urlencoded格式的數據
private function https_delete($url){$curl = curl_init();curl_setopt($curl, CURLOPT_URL, $url);curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);$output = curl_exec($curl);curl_close($curl);return $output;}
轉載于:https://www.cnblogs.com/oneboi/p/8301597.html
總結
- 上一篇: CentOS7.3的基本配置(建议学习用
- 下一篇: php接收post过来的json数据