From fc71e87dc55cdb1ae7bf8d6fb592c86d3f955f02 Mon Sep 17 00:00:00 2001 From: Mohannad Otaibi Date: Sun, 29 Nov 2015 01:26:57 +0300 Subject: [PATCH 1/2] Added support for PUT and DELETE Title describes all. --- application/libraries/mcurl.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/application/libraries/mcurl.php b/application/libraries/mcurl.php index 1db7248..a04d24e 100644 --- a/application/libraries/mcurl.php +++ b/application/libraries/mcurl.php @@ -32,6 +32,8 @@ * @category Libraries * @author Chad Hutchins * @link http://github.com/chadhutchins/codeigniter-mcurl + * @forkedBy Mohannad F. Otaibi + * @fork https://github.com/Mo9a7i/codeigniter-mcurl */ class Mcurl { @@ -108,6 +110,18 @@ function add_call($key=null, $method, $url, $params = array(), $options = array( curl_setopt($this->calls[$key]["curl"], CURLOPT_POSTFIELDS, $params); break; + case "PUT": + curl_setopt($this->calls[$key]["curl"], CURLOPT_URL, $url); + curl_setopt($this->calls[$key]["curl"], CURLOPT_CUSTOMREQUEST, $method); + curl_setopt($this->calls[$key]["curl"], CURLOPT_POSTFIELDS, $params); + break; + + case "DELETE": + curl_setopt($this->calls[$key]["curl"], CURLOPT_URL, $url); + curl_setopt($this->calls[$key]["curl"], CURLOPT_CUSTOMREQUEST, $method); + curl_setopt($this->calls[$key]["curl"], CURLOPT_POSTFIELDS, $params); + break; + case "GET": curl_setopt($this->calls[$key]["curl"], CURLOPT_URL, $url."?".$params); break; From ae5334c671d849b52e4311d6186c5d797a86ae67 Mon Sep 17 00:00:00 2001 From: Mohannad Otaibi Date: Sun, 29 Nov 2015 01:33:07 +0300 Subject: [PATCH 2/2] Samples for delete and put --- README.markdown | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 288ad2e..94f84d5 100644 --- a/README.markdown +++ b/README.markdown @@ -15,8 +15,10 @@ Move mcurl.php to your libraries folder. To view the examples in your applicatio // add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS ) $this->mcurl->add_call("call1","get","http://google.com"); $this->mcurl->add_call("call2","post","http://twitter.com"); - $this->mcurl->add_call("call3","get","http://google.com",array("q"=>"codeigniter")); - $this->mcurl->add_call("call4","get","https://facebook.com",array(),array(CURLOPT_SSL_VERIFYPEER => FALSE)); + $this->mcurl->add_call("call3","put","http://twitter.com"); + $this->mcurl->add_call("call4","delete","http://twitter.com"); + $this->mcurl->add_call("call5","get","http://google.com",array("q"=>"codeigniter")); + $this->mcurl->add_call("call6","get","https://facebook.com",array(),array(CURLOPT_SSL_VERIFYPEER => FALSE)); // execute the calls $responses = $this->mcurl->execute();