/**
* Quick static function to GET a URL
*/
- public static function quickGet($url, $accept=null)
+ public static function quickGet($url, $accept=null, $params=array())
{
+ if (!empty($params)) {
+ $params = http_build_query($params, null, '&');
+ if (strpos($url, '?') === false) {
+ $url .= '?' . $params;
+ } else {
+ $url .= '&' . $params;
+ }
+ }
+
$client = new HTTPClient();
if (!is_null($accept)) {
$client->setHeader('Accept', $accept);
return $response->getBody();
}
+ public static function quickGetJson($url, $params=array())
+ {
+ $data = json_decode(self::quickGet($url, null, $params));
+ if (is_null($data)) {
+ common_debug('Could not decode JSON data from URL: '.$url);
+ throw new ServerException('Could not decode JSON data from URL');
+ }
+ return $data;
+ }
+
/**
* Convenience function to run a GET request.
*