Re Twitter your twitter feed
knocked up a quick function to put the links back into my twitter feed, after i pull it down using their API.
it will take the text you input and create links around the @<username> #Hashtags and any links i.e. twitpic's etc. Not rocket science but could save you 30minutes of trying to get your head around regex again.
it will take the text you input and create links around the @<username> #Hashtags and any links i.e. twitpic's etc. Not rocket science but could save you 30minutes of trying to get your head around regex again.
function _twittertext($tweets) {
$tweets = preg_replace('/http:\/\/([\\d\\w.\/]+)/', '<a href="http://$1">http://$1</a>', $tweets);
$tweets = preg_replace('#@([\\d\\w]+)#', '<a href="http://twitter.com/$1">$0</a>', $tweets);
$tweets = preg_replace('/#([\\d\\w]+)/', '<a href="http://twitter.com/#search?q=%23$1">$0</a>', $tweets);
return $tweets;
}
Comments
Post a Comment