Skip to content

Commit

Permalink
Merge pull request #23 from andreustimm/master
Browse files Browse the repository at this point in the history
Support JSON PUT
  • Loading branch information
amouhzi committed Jun 4, 2016
2 parents 1f77f8c + b35e927 commit 38fc139
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Curl/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,21 @@ public function post($url, $data = array())
$this->_exec();
}

public function put($url, $data = array())
public function put($url, $data = array(), $json = 0)
{
$this->setopt(CURLOPT_URL, $url . '?' . http_build_query($data));
if ($json == 0) {
$url .= '?' . http_build_query($data);
} else {
$this->setopt(CURLOPT_POST, true);

if (is_array($data) || is_object($data)) {
$data = http_build_query($data);
}

$this->setopt(CURLOPT_POSTFIELDS, $data);
}

$this->setopt(CURLOPT_URL, $url);
$this->setopt(CURLOPT_CUSTOMREQUEST, 'PUT');
$this->_exec();
}
Expand Down

0 comments on commit 38fc139

Please sign in to comment.