public static function getStream()
    {
        $tweetStore = Store::get('Tweet');

        $consumerKey = Setting::getSetting('twitter', 'consumer_key');
        $consumerSecret = Setting::getSetting('twitter', 'consumer_secret');
        $accessToken = Setting::getSetting('twitter', 'access_token');
        $accessTokenSecret = Setting::getSetting('twitter', 'access_token_secret');
        $streamSearch = Setting::getSetting('twitter', 'stream_search');

        $twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);

        if (self::canCallAPI()) {
            self::updateLastAPICall();

            $stream = $twitter->search($streamSearch);

            foreach ($stream as $s) {
                if (!$tweetStore->getByTwitterIdForScope($s->id, 'stream')) {
                    $t = new Tweet;
                    $t->setTwitterId($s->id);
                    $t->setText($s->text);
                    $t->setHtmlText(Twitter::clickable($s));
                    $t->setScreenname($s->user->screen_name);
                    $t->setPosted($s->created_at);
                    $t->setCreatedDate(new \DateTime());
                    $t->setScope('stream');
                    $tweetStore->insert($t);
                }
            }
        }
    }
public static function getStream()
    {
        $tweetStore = Store::get('Tweet');

        $consumerKey = Setting::getSetting('twitter', 'consumer_key');
        $consumerSecret = Setting::getSetting('twitter', 'consumer_secret');
        $accessToken = Setting::getSetting('twitter', 'access_token');
        $accessTokenSecret = Setting::getSetting('twitter', 'access_token_secret');
        $streamSearch = Setting::getSetting('twitter', 'stream_search');

        $twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);

        if (self::canCallAPI()) {
            self::updateLastAPICall();

            $stream = $twitter->search($streamSearch);

            foreach ($stream as $s) {
                if (!$tweetStore->getByTwitterIdForScope($s->id, 'stream')) {
                    $t = new Tweet;
                    $t->setTwitterId($s->id);
                    $t->setText($s->text);
                    $t->setHtmlText(Twitter::clickable($s));
                    $t->setScreenname($s->user->screen_name);
                    $t->setPosted($s->created_at);
                    $t->setCreatedDate(new \DateTime());
                    $t->setScope('stream');
                    $tweetStore->insert($t);
                }
            }
        }
    }
public static function getStream ( ) { $ tweetStore = Store :: get ( 'Tweet' ) ; $ consumerKey = Setting :: getSetting ( 'twitter' , 'consumer_key' ) ; $ consumerSecret = Setting :: getSetting ( 'twitter' , 'consumer_secret' ) ; $ accessToken = Setting :: getSetting ( 'twitter' , 'access_token' ) ; $ accessTokenSecret = Setting :: getSetting ( 'twitter' , 'access_token_secret' ) ; $ streamSearch = Setting :: getSetting ( 'twitter' , 'stream_search' ) ; $ twitter = new Twitter ( $ consumerKey , $ consumerSecret , $ accessToken , $ accessTokenSecret ) ; if ( self :: canCallAPI ( ) ) { self :: updateLastAPICall ( ) ; $ stream = $ twitter -> search ( $ streamSearch ) ; foreach ( $ stream as $ s ) { if ( ! $ tweetStore -> getByTwitterIdForScope ( $ s -> id , 'stream' ) ) { $ t = new Tweet ; $ t -> setTwitterId ( $ s -> id ) ; $ t -> setText ( $ s -> text ) ; $ t -> setHtmlText ( Twitter :: clickable ( $ s ) ) ; $ t -> setScreenname ( $ s -> user -> screen_name ) ; $ t -> setPosted ( $ s -> created_at ) ; $ t -> setCreatedDate ( new \ DateTime ( ) ) ; $ t -> setScope ( 'stream' ) ; $ tweetStore -> insert ( $ t ) ; } } } }
Get the stream of tweets for the search term and cache to the database
Get the stream of tweets for the search term and cache to the database