/**
  * Retrieve an array of social network status updates.
  *
  * @return array
  */
 public function getArray()
 {
     // These classes had a breakup :(
     // ---------------------------------------------------
     // The tight coupling between our status retrieval class
     // and our Twitter API class has been loosened. Each class
     // now has its own single responsibility.
     $twitterFeedReader = new TwitterFeedReader();
     return $twitterFeedReader->getMessages();
 }
 /**
  * Retrieve an array of social network status updates.
  *
  * @return array
  */
 public function getArray()
 {
     // No instantiationinginging!
     // ---------------------------------------------------
     // This time we don't need to create a new instance of
     // our TwitterFeedReader object. Instead we can use
     // the instance that has been injected through the
     // constructor of the class.
     //
     // So, we are now using dependency injection. Job done,
     // right? Better take a look at the tests.
     return $this->twitterFeedReader->getMessages();
 }
 /**
  * Retrieve an array of social network status updates.
  *
  * @return array
  */
 public function getArray()
 {
     return $this->twitterFeedReader->getMessages();
 }
Example #4
0
<?php

require_once 'TwitterFeedReader.php';
$twitter = new TwitterFeedReader('user', 'nabazmaaruf', 10);
foreach ($twitter->tweets as $twitter->tweet) {
    $data[] = array('name' => $twitter->author('name'), 'screen_name' => '@' . $twitter->author('screen_name'), 'profile_img' => $twitter->userAvatar(), 'twitter_content' => $twitter->tweetHTML(), 'retweet_count' => 'Retweeted: ' . $twitter->retweetCount());
}
echo json_encode($data);