Midterm :

My midterm project was a made making use of the word cloud code and a little PHP. Since this class deals with text i thought i will make use of the twitter API to pull tweets from twitter and use that as input for the word cloud program.

For pulling the tweets I used PHP. Since the word cloud program requires a text file as input I had to parse the xml feed of twitter and then save it to a txt file on the server and feed that text file as input for the word cloud.

$file = “http://twitter.com/statuses/public_timeline.xml?count=200″; is the link for the public timeline of twitter in xml.

The php code is as follows :

<META HTTP-EQUIV=”refresh” CONTENT=”15; URL=http://www.sanjaypapinazath.com/a2z/twit_pull6.php”>

ini_set(‘display_errors’, true);
ini_set(‘display_startup_errors’, true);

$file = “http://twitter.com/statuses/public_timeline.xml?count=200”;


$currentTag = “”;

function contents($parser, $data){
$fp1=fopen(‘/home/sanjaypa/public_html/a2z/twit_pull.txt’,’a ‘);
global $currentTag;
if ($currentTag == ‘TEXT’ || $currentTag == ‘NAME’) {
echo “$data<br/>”;
fwrite($fp1, $data);


function startTag($parser, $name){
global $currentTag;
$currentTag = $name;
// echo “<b>”;

function endTag($parser, $data){
// echo “</b><br />”;
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, “startTag”, “endTag”);
xml_set_character_data_handler($xml_parser, “contents”)
$fp = fopen($file, “r”);
$data = fread($fp, 80000);
if(!(xml_parse($xml_parser, $data, feof($fp)))){
die(“Error on line ” . xml_get_current_line_number($xml_parser));


In the processing sketch i made use of the SMS library which makes use of the accelerometer in the laptop.

So when the sketch is running and the laptop is tilted upwards the words used more will go up.

o/p :picture-1.png

This entry was posted on Thursday, March 19th, 2009 at 8:55 pm and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply