diff --git a/spouts/twitter/hometimeline.php b/spouts/twitter/hometimeline.php index c63ca57ae4..f19aba4ca8 100644 --- a/spouts/twitter/hometimeline.php +++ b/spouts/twitter/hometimeline.php @@ -91,10 +91,17 @@ class hometimeline extends \spouts\twitter\usertimeline { public function load($params) { $twitter = new \TwitterOAuth($params['consumer_key'], $params['consumer_secret'], $params['access_key'], $params['access_secret']); $timeline = $twitter->get('statuses/home_timeline', array('include_rts' => 1, 'count' => 50)); - - if(isset($timeline->error)) - throw new \exception($timeline->error); - + + if (isset($timeline->errors)) { + $errors = ''; + + foreach ($timeline->errors as $error) { + $errors .= $error->message . "\n"; + } + + throw new \Exception($errors); + } + if(!is_array($timeline)) throw new \exception('invalid twitter response'); diff --git a/spouts/twitter/listtimeline.php b/spouts/twitter/listtimeline.php index 7be1f039e7..e4c97dcad3 100644 --- a/spouts/twitter/listtimeline.php +++ b/spouts/twitter/listtimeline.php @@ -79,10 +79,17 @@ public function load($params) { 'owner_screen_name' => $params['owner_screen_name'], 'include_rts' => 1, 'count' => 50)); - - if(isset($timeline->error)) - throw new \exception($timeline->error); - + + if (isset($timeline->errors)) { + $errors = ''; + + foreach ($timeline->errors as $error) { + $errors .= $error->message . "\n"; + } + + throw new \Exception($errors); + } + if(!is_array($timeline)) throw new \exception('invalid twitter response'); diff --git a/spouts/twitter/usertimeline.php b/spouts/twitter/usertimeline.php index 456fe47eda..e9551e789c 100644 --- a/spouts/twitter/usertimeline.php +++ b/spouts/twitter/usertimeline.php @@ -179,10 +179,17 @@ public function load($params) { $access_token_used = !empty($params['access_token']) && !empty($params['access_token_secret']); $twitter = new \TwitterOAuth($params['consumer_key'], $params['consumer_secret'], $access_token_used ? $params['access_token'] : null, $access_token_used ? $params['access_token_secret'] : null); $timeline = $twitter->get('statuses/user_timeline', array('screen_name' => $params['username'], 'include_rts' => 1, 'count' => 50)); - - if(isset($timeline->error)) - throw new \exception($timeline->error); - + + if (isset($timeline->errors)) { + $errors = ''; + + foreach ($timeline->errors as $error) { + $errors .= $error->message . "\n"; + } + + throw new \Exception($errors); + } + if(!is_array($timeline)) throw new \exception('invalid twitter response');