public function onRun() { try { $latestTweet = TwitterClient::instance()->getLatestTweet(["tweet-limit" => $this->property('tweet-limit'), "exclude-replies" => $this->property('exclude-replies')]); } catch (Exception $ex) { return []; } $this->page["tweets"] = $latestTweet; }
/** * Returns the favourite tweet feed. */ public function all() { $favorites = TwitterClient::instance()->listFavorites(); if (!$this->property('random')) { return array_slice($favorites, 0, $this->property('count')); } $randomKeys = array_rand($favorites, $this->property('count')); if (!is_array($randomKeys)) { $randomKeys = [$randomKeys]; } $result = []; foreach ($randomKeys as $key) { $result[] = $favorites[$key]; } return $result; }