From: Michael J. Rubinsky Date: Mon, 20 Jul 2009 22:14:17 +0000 (-0400) Subject: try/catch with some slight hacks to deal with no error messages available X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=68e0ff7c7cb2b29fa98f9d9054250b28a77f893c;p=horde.git try/catch with some slight hacks to deal with no error messages available with our Http_Client library. --- diff --git a/framework/Service_Twitter/lib/Horde/Service/Twitter/Request/Oauth.php b/framework/Service_Twitter/lib/Horde/Service/Twitter/Request/Oauth.php index 0adecbc42..fa58c7148 100644 --- a/framework/Service_Twitter/lib/Horde/Service/Twitter/Request/Oauth.php +++ b/framework/Service_Twitter/lib/Horde/Service/Twitter/Request/Oauth.php @@ -27,7 +27,14 @@ class Horde_Service_Twitter_Request_Oauth extends Horde_Service_Twitter_Request $this->_twitter->auth->oauth, $this->_twitter->auth->getAccessToken()); $client = new Horde_Http_Client(); - $response = $client->get($url, array('Authorization' => $request->buildAuthorizationHeader('Twitter API'))); + try { + $response = $client->get($url, array('Authorization' => $request->buildAuthorizationHeader('Twitter API'))); + } catch (Horde_Http_Client_Exception $e) { + // Currently we can't obtain any information regarding the resposne + // when a 4xx/5xx response is rec'd due to fopen() failing. + // For now, fake it and return the error from the exception. + return '{"request":"' . $url . '", "error:", "' . $e->getMessage() . '"}'; + } return $response->getBody(); } @@ -40,7 +47,14 @@ class Horde_Service_Twitter_Request_Oauth extends Horde_Service_Twitter_Request $this->_twitter->auth->getAccessToken()); $client = new Horde_Http_Client(); - $response = $client->post($url, $params, array('Authorization' => $request->buildAuthorizationHeader('Twitter API'))); + try { + $response = $client->post($url, $params, array('Authorization' => $request->buildAuthorizationHeader('Twitter API'))); + } catch (Horde_Http_Client_Exception $e) { + // Currently we can't obtain any information regarding the resposne + // when a 4xx/5xx response is rec'd due to fopen() failing. + // For now, fake it and return the error from the exception. + return '{"request":"' . $url . '", "error:", "' . $e->getMessage() . '"}'; + } return $response->getBody(); } diff --git a/framework/Service_Twitter/lib/Horde/Service/Twitter/Statuses.php b/framework/Service_Twitter/lib/Horde/Service/Twitter/Statuses.php index ee7628c57..3a4a99810 100644 --- a/framework/Service_Twitter/lib/Horde/Service/Twitter/Statuses.php +++ b/framework/Service_Twitter/lib/Horde/Service/Twitter/Statuses.php @@ -68,4 +68,11 @@ class Horde_Service_Twitter_Statuses return $this->_twitter->request->post($url, $params); } + + public function friendsTimeline($params = array()) + { + $url = $this->_endpoint . 'friends_timeline.' . $this->_format; + return $this->_twitter->request->get($url); + } + } diff --git a/framework/Service_Twitter/lib/Horde/Service/Twitter/Timeline.php b/framework/Service_Twitter/lib/Horde/Service/Twitter/Timeline.php deleted file mode 100644 index b3d9bbc7f..000000000 --- a/framework/Service_Twitter/lib/Horde/Service/Twitter/Timeline.php +++ /dev/null @@ -1 +0,0 @@ -