diff options
author | Evan Prodromou <evan@status.net> | 2009-12-15 16:24:52 -0500 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2009-12-15 16:24:52 -0500 |
commit | 2a1468ec8b2918553b490ddaef6bdede3e2d5b1b (patch) | |
tree | c94a68a1239a5a3c35d5564323967fcd4ff14523 /plugins/TwitterBridge/twitterbasicauthclient.php | |
parent | e9b733e7f036bc03353ae6dd7b096ea179698a4d (diff) | |
parent | f3d27cc3ae92e2b7412dd998d7de7a2b58dc8e6a (diff) |
Merge branch '0.9.x' into testing
Diffstat (limited to 'plugins/TwitterBridge/twitterbasicauthclient.php')
-rw-r--r-- | plugins/TwitterBridge/twitterbasicauthclient.php | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/plugins/TwitterBridge/twitterbasicauthclient.php b/plugins/TwitterBridge/twitterbasicauthclient.php index 7ee8d7d4c..fd26293f9 100644 --- a/plugins/TwitterBridge/twitterbasicauthclient.php +++ b/plugins/TwitterBridge/twitterbasicauthclient.php @@ -32,6 +32,20 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { } /** + * General Exception wrapper for HTTP basic auth errors + * + * @category Integration + * @package StatusNet + * @author Zach Copley <zach@status.net> + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + */ +class BasicAuthException extends Exception +{ +} + +/** * Class for talking to the Twitter API with HTTP Basic Auth. * * @category Integration @@ -169,12 +183,13 @@ class TwitterBasicAuthClient } /** - * Make a HTTP request using cURL. + * Make an HTTP request * * @param string $url Where to make the request * @param array $params post parameters * * @return mixed the request + * @throws BasicAuthException */ function httpRequest($url, $params = null, $auth = true) { @@ -199,6 +214,12 @@ class TwitterBasicAuthClient $response = $request->get($url); } + $code = $response->getStatus(); + + if ($code < 200 || $code >= 400) { + throw new BasicAuthException($response->getBody(), $code); + } + return $response->getBody(); } |