X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2FTwitterBridge%2Ftwitterbasicauthclient.php;h=fd26293f9e40acf54ff4e63402c61813866cbd99;hb=1554510c8437f9dcf26d1bc28252549149473e5c;hp=d1cf45aec608f0d0f4d9836d008f6c4feb724a95;hpb=eaae5a4c90249330034e8ee1004e85ae6399fe70;p=quix0rs-gnu-social.git diff --git a/plugins/TwitterBridge/twitterbasicauthclient.php b/plugins/TwitterBridge/twitterbasicauthclient.php index d1cf45aec6..fd26293f9e 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) { @@ -183,7 +198,8 @@ class TwitterBasicAuthClient 'follow_redirects' => true, 'connect_timeout' => 120, 'timeout' => 120, - 'ssl_verifypeer' => false, + 'ssl_verify_peer' => false, + 'ssl_verify_host' => false )); if ($auth) { @@ -198,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(); }