Create Twitter RSS Of Your Tweets Based On Keywords
12:53 pm on October 23rd, 2009 | Hits: 431
Posted in Tips & Tricks


As i started testing and creating a script for my blog sidebar column, many asked me how i did it. Well basically it is a very simply PHP script which uses Simplepie engine to create a RSS feed based on keyword matching. Basically my current sidebar script will show an RSS feed of my tweets which contains the keyword #x3m.

So in order for me to choose which tweets appear on my sidebar i simply add a channel keyword #x3m to my tweets and it will appear instantly on my sidebar. As we know Simplepie lets you recreate RSS feed out of any RSS feed with PHP coding mixed. So how to have this done? Here is the idea. Get your Twitter RSS ready, pass it into another RSS feed using Simplepie, but this time do a keyword matching using PHP to show only the tweets with the keyword and display it out.

Example (Sample Simplepie Code):

<?php if ($success): ?>
<? $itemlimit=0; ?>
<?php foreach($feed->get_items() as $item): ?>
<? if ($itemlimit==50) { break; } ?>

<?
//keyword to search in tweets
$keyword = "*uniquekey";

//check if the keyword exist in the item_title
$item_title = $item->get_title();

if ( strpos($item_title, $keyword ) === false )
{
 $message = "no matching found";
}
else {
 $message = "you can create the RSS output here";
}
?>

<? $itemlimit++ ?>
<?php endforeach; ?>
<?php endif; ?>

What this Simplepie code does is go through 50 of your Tweet posts and matches it with the given keyword (*uniquekey) and returns post only containing the keyword. I am sorry i could not post the entire script as the code is really messy and was only meant for usability purpose. If you need further help or assistance do get hold of me on twitter and direct message me @extremesh.





Related Posts

Display Simplepie RSS Feed In Reverse Order - Posted @ 11:45 pm on February 28th, 2010
SimplePie and mySQL Special Character Issue - Posted @ 2:25 pm on July 4th, 2008
Check Latest Twitter Updates Based On Keywords Using Google - Posted @ 1:38 pm on January 15th, 2010


Recommended



Comments

Leave a comment:

Your comment :

 
About Me

I'm ramesh from Perak, Malaysia. Blogging is my hobby hence this blog is my second home to share my life, interests and etc.



Blog Menu



Recent Friends



 

page made and maintained by mesh