Display Twitter Feed on Polycom

Twitter feed on the Polycom

Twitter feed on the Polycom

Well I got this new IP Phone replacing our old PSTN phones. But the LCD screen on the phone looked bit boring.

There were few ideas how I can use this realestate to do something interseting.

  1. Display the train timetable (Metlink doesn’t give you a clean API to scrape the time tables, and I don’t have time to write a script scrape the data from its bulky website. )
  2. Weather (Kind of boring to watch it all the time)
  3. What’s people talking about your company on  Twitter, and thats what I did…..

My Ugly Bash Script

#!/bin/bash
text=`export http_proxy=http://xx.xx.xx.xx && /usr/local/extractSearch.pl`
convert -size 160x75 -monochrome -depth 1 -type Bilevel -gravity center caption:"Twitter Feed\n$text" /var/www/polycom/image.bmp

The Perl Script
#!/usr/bin/perl
# use module
use XML::Simple;
use LWP::UserAgent;
use Data::Dumper;
# create object
$xml = new XML::Simple;
my $url = "http://search.twitter.com/search.atom?q=<Your Query>&rpp=1&page=1&locale=en";
my $ua = LWP::UserAgent->new();
$ua->env_proxy;
$ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');
$ua->timeout(30);
$ua->default_header('pragma' => "no-cache", 'max-age' => '0');
my $res = $ua->get($url);
$data = $xml->XMLin($res->content);
print "$data->{entry}->{title}"

Leave a comment