<?php
// https://dev.twitter.com
$connection = new TwitterOAuth('5lHdwi40pbnZnrby501oQQ', 'WEcldvg53DztO1WqKZX2W4Sea304WW1awtjTBsHw', '288241788-7ojQLvf36QZpjz981MjRJe8v8tM4IssnH1FqcGr3', '9K3EznjdPyLMNW65bdCAphEfHgxEz4fNWvNLzaf4ys');
$tweets = $connection->get('statuses/user_timeline', array('count' => 5));
?>
<div id="tweet">
	<div class="wrapper">
		<div class="rubanTwitter"><img src="<?php echo  URL::to_asset('image/ruban-twitter@2x.png'); ; ?>" alt="" title="" /></div>
		<div id="twitterCycle">
			<?php foreach($tweets as $t): ?>
				<?php
				$hashtag = preg_replace('/(^|\s)#(\w*[a-zA-Z_]+\w*)/', '<a href="https://twitter.com/search?q=%23\2&src=hash" target="_blank">\1#\2</a>', $t->text);
				$link = preg_replace('/http:\/\/([a-z0-9_\.\-\+\&\!\#\~\/\,]+)/i', '<a href="http://$1" target="_blank">http://$1</a>', $hashtag);
				$text = preg_replace('/@(\w+)/i', '<a href="http://twitter.com/$1" target="_blank">$0</a>', $link);
				?>
				<div class="tweetTxt">
					<i class="icon-quote-left"></i><?php echo  $text ; ?><i class="icon-quote-right"></i>
				</div>
			<?php endforeach; ?>
		</div>
	</div>
</div>
<script type="text/javascript">
	$(window).load(function(){
		$('#twitterCycle').cycle({
		    fx:      'scrollDown', 
			easeIn:  'easeOutBack', 
		    speed:    500,
		    timeout:  4000
		});
	});
</script>