Track Your Favorite Topic on Twitter: A PHP CLI Tool

Here’s a little php utility that will let you watch the Twitter public time line for your favorite topic. This is specially helpful for those who want to build some tracking application on the basis of the twitter streaming APIs.

Here’s the source:

<?php
$topic = $argv[1];
if(empty ($topic)) {
    $topic = "php";
}
$username = "twitter_username";
$password = "twitter_password";
$fp = fopen("http://{$username}:{$password}@stream.twitter.com/1/statuses/filter.json?track={$topic}","r");
while( $data = fgets($fp) ) {
    $tweet = json_decode($data,true);
    if(!empty($tweet['text'])) {
        echo $tweet['user']['screen_name'].": ".$tweet['text']." \n -------------------- \n";
    }
}
?>

Run this script with the keyword as the argument:

php twitter.php keyword
This entry was posted in Blog Post and tagged , . Bookmark the permalink.

5 Responses to Track Your Favorite Topic on Twitter: A PHP CLI Tool

  1. Pingback: Twitted by masnun

  2. Pingback: Webby Scripts Track Your Favorite Topic on Twitter: A PHP CLI Tool « maSnun.com

  3. Pingback: Track Your Favorite Topic on Twitter: A PHP CLI Tool « maSnun.com | Coder Online

  4. Pingback: Tweets that mention Track Your Favorite Topic on Twitter: A PHP CLI Tool « maSnun.com -- Topsy.com

  5. Rosio Mettler says:

    Twitter gave me a HUGE boost in the Google rankings

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">