quickGetJson for HTTP requests to return json objects

This commit is contained in:
Mikael Nordfeldth 2015-11-30 02:05:06 +01:00
parent b7edac2610
commit 8bab642cc7

View File

@ -200,6 +200,16 @@ class HTTPClient extends HTTP_Request2
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.
*