natatkinson
7/22/2014 - 3:04 PM

Twiiter Feed For User

Twiiter Feed For User

<?php

/*INCLUDE TWITTER WRAPPER: https://github.com/j7mbo/twitter-api-php */
include_once "twitter_2013.php";
$twitter = new twitter();

$user = "EIU";
$number = 10;

$timeline = $twitter->user_timeline($user,$number);
?>

<div id="twitter_div" class="front_module">
<h2>Twitter Updates</h2>
<ul id="twitter_update_list">
	
	<?php foreach($timeline as $status){ ?>
		<li><?php 
			
			$status['text'] = preg_replace('@(https?://([-\w\.]+)+(/([\w/_\.]*(\?\S+)?(#\S+)?)?)?)@','<a href="$1">$1</a>',$status['text']);
			$status['text'] = preg_replace('/@(\w+)/','<a href="http://twitter.com/$1">@$1</a>',$status['text']);
			$status['text'] = preg_replace('/\s+#(\w+)/',' <a href="https://twitter.com/search?q=%23$1">#$1</a>',$status['text']);
			
			$timestamp = date("d M",strtotime($status['created_at']));
		
		if($status['user']['profile_image_url']){?><img src="<?php echo $status['user']['profile_image_url'];?>" width="32" height="32" align="left" style="padding: 0 5px 2px 0;"> <?php }
		echo $status['text']. " <em>".$timestamp;?></em><br class="clear"></li>

		
	<?php } ?>
</ul>
<a href="http://twitter.com/<?php echo $user;?>" id="twitter-link" style="display:block;text-align:right;">follow me on Twitter</a>
</div>