Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Twitter Feed ##
- *
- * @package WordPress
- * @subpackage 4Trees
- * @since 0.2
- */
- // grab tweets ##
- $args = array(
- 'debug' => false, // debug returned object and errors ##
- 'consumer_key' => "###########", /* consumer key - https://dev.twitter.com/apps/ */
- 'consumer_secret' => "###########", /* consumer secret */
- 'oauth_access_token' => "###########", /* generated oauth access token */
- 'oauth_access_token_secret' => "###########", /* generated oauth access token secret */
- 'mode' => 'search', /* search, home_timeline, user_timeline */
- 'count' => 200,
- 'search' => 'from:BBCWorld OR from:nytimes',
- );
- $twitter_data = ftf_twitter( $args );
- foreach ( $twitter_data as $tweet ) {
- // grab text ##
- $text = $tweet->text;
- // apply filtering ##
- if (
- preg_match( "/\bnano/i", $text ) // "nano*" found ##
- /*
- && // AND ##
- preg_match( "/\bregulat|toxic/i", $text ) // " regulat* OR toxic* " found ##
- || // OR ##
- (
- preg_match( "/\b(?:risk|hazard)\b/i", $text ) // " risk OR hazard " found ##
- && // AND ##
- preg_match( "/\b(?:exposure|release)\b/i", $text ) // " exposure OR release " found ##
- )
- */
- ){
- // format text correctly ##
- $tweet->text = ftf_twitter_add_href($tweet->text); // add href link ##
- $tweet->text = ftf_twitter_add_username($tweet->text); // add username link ##
- $tweet->text = ftf_twitter_add_hashtag($tweet->text); // add hashtag link ##
- ?>
- <li>
- <div class="avatar">
- <a rel="nofollow" target="_blank" class="mt_avatar" href="http://twitter.com/<?php echo $tweet->user->screen_name; ?>">
- <img src="<?php echo $tweet->user->profile_image_url; ?>" alt="<?php echo $tweet->user->name; ?>" border="0" class="icon"/>
- </a>
- </div>
- <div class="meta">
- <div class="mt_header">
- <a rel="nofollow" target="_blank" class="mt_user" href="http://twitter.com/<?php echo $tweet->user->screen_name; ?>">
- <?php echo $tweet->user->name; ?>
- </a>
- <span class="mt_screen_name">@<?php echo $tweet->user->screen_name; ?></span>
- </div>
- <div class="mt_text"><?php echo $tweet->text; ?></div>
- <div class="mt_footer">
- <?php
- // format date correctly ##
- $date = date("j M Y", strtotime($tweet->created_at)); // 1 Jul 2011
- ?>
- <div class="time"><?php echo $date; ?></div>
- <?php
- // if retweet ##
- if ( $tweet->entities->retweeted === true ) {
- ?>
- <span class="image_r"></span>Retweeted by <a rel="nofollow" target="_blank" class="mt_retweet" href="http://twitter.com/<?php echo $tweet->user->screen_name; ?>"><?php echo $tweet->user->name; ?></a>
- <?php
- }
- // end retweet ##
- ?>
- </div>
- </div>
- </li>
- <?php
- } // filters ##
- } // loop ##
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement