Skip to content

Commit 0eb49b6

Browse files
committed
Update Curl.php
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.
1 parent e51c182 commit 0eb49b6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Curl/Curl.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ public function __construct() {
5050
}
5151

5252
public function get($url, $data = array()) {
53-
$this->setopt(CURLOPT_URL, $url . '?' . http_build_query($data));
53+
if (count($data) > 0)
54+
$this->setopt(CURLOPT_URL, $url . '?' . http_build_query($data));
55+
else
56+
$this->setopt(CURLOPT_URL, $url);
5457
$this->setopt(CURLOPT_HTTPGET, TRUE);
5558
$this->_exec();
5659
}

0 commit comments

Comments
 (0)