The folks over at Think Vitamin had a jolly clever idea about using Twitter and #tags to create a micro-blog, which they have used to power the news section on the Think Vitamin site.
Ryan Carson wrote a great write up on how they had gone about doing this but it turns out I can’t run atom-html.php on my servers – so this is my variation on their concept.
How do you do it then?
I’m not one to steal other peoples thunder – so follow the guide here at Think Vitamin – They cover why you’d want to do it, where to start, how choose your hash tag and to find your create your atom feed. When you get to Output the Atom Feed as HTML section head back here.
Right – done all that? Good.
Now, on the servers I host this site on allow_url_fopen() is a disabled function due security risk it poses (please don’t ask me anything else about this – that’s what I was told!) so I can’t use so the atom-html.php file that Ryan uses.
MagpieRSS was recommended to me and its pretty easy to set up.
So, down download the MagpieRSS files from here.
Once you’ve got that downloaded open the MagpeRSS folder create a new folder on your hosting space called magpierss and upload these files: rss_fetch.inc, rss_parser.inc, rss_cache.inc, and rss_utils.inc plus the directory extlib in to the folder you just created. It is all explaned in the INSTALL doc that comes with MagpieRSS if you get lost.
Still with me? Ace. Now you need to create a new .php webpage (or use an existing .php page). Somewhere in the <body> tags add the following code:
<?php
require_once(‘magpierss/rss_fetch.inc’);
$url = ‘http://www.yourtwittersearchfeedhere.com’;
$rss = fetch_rss( $url );
echo “<ul>”;
$count=1;
foreach ($rss->items as $item) {
echo “<li>”. “”. $item['title'] .”</a></li>”;
$count ++;
if($count==10){ break;}
}
echo “</ul>”;
?>
Replace http://www.yourtwittersearchfeedhere.com with the feed you copied from http://search.twitter.com/
If you don’t want to limit the number of tweets you display remove:
$count ++;
if($count==10){ break;}
Then save and upload. A there you go – your very own twitter powered micro-blog.
You can style the feed using the <li> tag. For example on my example site I have styled it like this:
li {
color:#666;
font-size:120%;
margin:20px 0 ;
padding-bottom:20px;
border-bottom: solid 1px #111;
border-right:30px solid #000;
}
I’m sure there is loads more that can be done – if you’ve any ideas let me know. The next thing I’d like to do is hide the #tag or at least style it and maybe add the date and time the tweet was posted, but that will have to wait until I have more time to explore MagpieRSS.
Here’s any example of it in action: http://www.blogbyben.co.uk/fitness
Thanks to Ryan Carson of Carsonifed and Think Vitamin for the idea and inspiration.







