From 0eb49b6117eee0611023b278b0cb544e2b734d34 Mon Sep 17 00:00:00 2001 From: giantguido Date: Sun, 22 Jun 2014 17:15:15 +0200 Subject: [PATCH] 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. --- src/Curl/Curl.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index d087023..48b6ae5 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -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(); }