From 0ccf34b6567c5cfc9f06f306ca3697bca6489327 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Fri, 9 Jun 2017 07:45:59 -0700 Subject: [PATCH] use consistent pattern for fetching from silos --- lib/XRay/Fetcher.php | 14 +------------- lib/XRay/Formats/Twitter.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/lib/XRay/Fetcher.php b/lib/XRay/Fetcher.php index 608baea..3e37789 100644 --- a/lib/XRay/Fetcher.php +++ b/lib/XRay/Fetcher.php @@ -145,19 +145,7 @@ class Fetcher { ]; } - $tweet = Formats\Twitter::fetch($url, $creds); - if(!$tweet) { - return [ - 'error' => 'twitter_error', - 'error_description' => $e->getMessage() - ]; - } - - return [ - 'url' => $url, - 'body' => $tweet, - 'code' => 200, - ]; + return Formats\Twitter::fetch($url, $creds); } private function _fetch_github($url, $opts) { diff --git a/lib/XRay/Formats/Twitter.php b/lib/XRay/Formats/Twitter.php index 7462dd5..db2fd9c 100644 --- a/lib/XRay/Formats/Twitter.php +++ b/lib/XRay/Formats/Twitter.php @@ -33,10 +33,17 @@ class Twitter extends Format { try { $tweet = $twitter->request('statuses/show/'.$tweet_id, 'GET', ['tweet_mode'=>'extended']); } catch(\TwitterException $e) { - return false; + return [ + 'error' => 'twitter_error', + 'error_description' => $e->getMessage() + ]; } - return $tweet; + return [ + 'url' => $url, + 'body' => $tweet, + 'code' => 200, + ]; } public static function parse($json, $url) {