Skip to content

Commit

Permalink
Update Curl.php
Browse files Browse the repository at this point in the history
Sometimes, e.g. when you want to perform a get request using same name parameters in the query, it is preferred to build the url with the query parameters in the $url argument and not specify a $data argument. In that case, you do not want a '?' put behind your url, as it messes up the query.
  • Loading branch information
giantguido committed Jun 22, 2014
1 parent e51c182 commit 0eb49b6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Curl/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ public function __construct() {
}

public function get($url, $data = array()) {
$this->setopt(CURLOPT_URL, $url . '?' . http_build_query($data));
if (count($data) > 0)
$this->setopt(CURLOPT_URL, $url . '?' . http_build_query($data));
else
$this->setopt(CURLOPT_URL, $url);
$this->setopt(CURLOPT_HTTPGET, TRUE);
$this->_exec();
}
Expand Down

0 comments on commit 0eb49b6

Please sign in to comment.