|
@@ -802,6 +802,18 @@
|
|
|
|
|
|
try {
|
|
try {
|
|
if ($method == 'GET') {
|
|
if ($method == 'GET') {
|
|
|
|
+ if (count($data) > 0) {
|
|
|
|
+ $url = parse_url($url);
|
|
|
|
+ if (isset($url['query'])) {
|
|
|
|
+ $query = [];
|
|
|
|
+ parse_str($url['query'], $query);
|
|
|
|
+ $url['query'] = http_build_query(array_merge($query, $data));
|
|
|
|
+ } else {
|
|
|
|
+ $url['query'] = http_build_query($data);
|
|
|
|
+ }
|
|
|
|
+ $url = $this->unparse_url($url);
|
|
|
|
+ }
|
|
|
|
+
|
|
$response = Requests::get($url, $headers, $options);
|
|
$response = Requests::get($url, $headers, $options);
|
|
} else if ($method == 'POST') {
|
|
} else if ($method == 'POST') {
|
|
$response = Requests::post($url, $headers, json_encode(['data' => $data]), $options);
|
|
$response = Requests::post($url, $headers, json_encode(['data' => $data]), $options);
|
|
@@ -829,4 +841,23 @@
|
|
$this->lastResponse = $data;
|
|
$this->lastResponse = $data;
|
|
return $data;
|
|
return $data;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Take an array from parse_url and turn it back into a URL.
|
|
|
|
+ *
|
|
|
|
+ * @param $parsed_url Array from parse_url.
|
|
|
|
+ * @return String representing the URL.
|
|
|
|
+ */
|
|
|
|
+ function unparse_url($parsed_url) {
|
|
|
|
+ $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
|
|
|
|
+ $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
|
|
|
|
+ $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
|
|
|
|
+ $user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
|
|
|
|
+ $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
|
|
|
|
+ $pass = ($user || $pass) ? "$pass@" : '';
|
|
|
|
+ $path = isset($parsed_url['path']) ? $parsed_url['path'] : '';
|
|
|
|
+ $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
|
|
|
|
+ $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
|
|
|
|
+ return "$scheme$user$pass$host$port$path$query$fragment";
|
|
|
|
+ }
|
|
}
|
|
}
|