From 467fe39567b5d7342b0537be32b54d4eefaf4433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Rog=C3=A9rio?= Date: Tue, 1 Nov 2016 11:37:20 -0200 Subject: [PATCH] Created a method to render tweets --- request.php | 9 ++------- vendor/Tweets/Tweets.class.php | 9 +++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/request.php b/request.php index 4fcac48..668ed95 100644 --- a/request.php +++ b/request.php @@ -10,10 +10,5 @@ use Tweets\Tweets; -$tweets = new Tweets(); -$timeline = $tweets->user_timeline(); -$hashtag = $tweets->hashtag(); - -header('Content-type: application/json'); - -echo $json = (isset($_GET['hashtag'])) ? $hashtag : $timeline; \ No newline at end of file +$tweets = new Tweets(); +$tweets->render(); \ No newline at end of file diff --git a/vendor/Tweets/Tweets.class.php b/vendor/Tweets/Tweets.class.php index cde97df..5dc724f 100644 --- a/vendor/Tweets/Tweets.class.php +++ b/vendor/Tweets/Tweets.class.php @@ -37,4 +37,13 @@ public function hashtag() { return json_encode($data); } + + public function render() { + $timeline = $this->user_timeline(); + $hashtag = $this->hashtag(); + + header('Content-type: application/json'); + + echo $json = (isset($_GET['hashtag'])) ? $hashtag : $timeline; + } } \ No newline at end of file