From 656d29080a3369d3037959e3ecdd62d36a7cc5e1 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 14 Dec 2009 07:33:29 +0000 Subject: Fix Twitter bridge so it responds reasonably to authorization errors. --- plugins/TwitterBridge/twitterbasicauthclient.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'plugins/TwitterBridge/twitterbasicauthclient.php') 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 @@ -31,6 +31,20 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +/** + * General Exception wrapper for HTTP basic auth errors + * + * @category Integration + * @package StatusNet + * @author Zach Copley + * @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. * @@ -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(); } -- cgit v1.2.3