NURUL FERDOUS

Create your IM bot for gtalk/jabber/aim/yahoo with imified API

Posted on: December 30, 2008

Recently I made a news bot named news@bot.im AKA newsbot24@yahoo.com with the help of a wrapper class wrote by Hasin Hayder. This cool API has been provided by imified recently to make your application IM enable easily . You may test my bot by sending any instant message to newsbot24@yahoo.com or sending a message from your GTalk. It will grab one of the latest 25 top news from http://www.news.google.com or http://www.bdnews24.com RSS feed. I have set caching time as 1200 so that it can be easily work with very less bandwidth. I used lastRSS class to grab the RSS feed as I am having some freight to use Google feed parser with JSON 😦

You can make one just for FREE from http://www.bot.im All you need is to DOWNLOAD the wrapper class to do it quick. Alternatively you may read the quick and dirty documentation from HERE.

Now lemme reveal the source code I used for my news bot :p

<?php
// include lastRSS
include "lastRSS.php";
include "class.imified.php";
// Set cache dir and cache time limit (1200 seconds)
// (don't forget to chmod cahce dir to 777 to allow writing)
$rss->cache_dir = './temp';
$rss->cache_time = 1200;
$rss->cp = 'UTF-8';
$rss->date_format = 'l';
//initiating bot...
//@param pass your imified user credentials
$im = new ImifiedHelper("YOUR-API-KEY-GIVEN-FROM-IMIFIED","DEVELOPERS-NAME","PASSWORD");
if(!isset($_REQUEST['msg']))
{
    echo "This is a newsbot. You may add it as news@bot.im or newsbot24@yahoo.com";
    die();
}

//callback
$im->setCallback("callback");
function callback($message, $step, $network, $userKey)
{
    global $im;
    $message = strtolower($message);
    if("inews" == $message){
        // Create lastRSS object
        $rss = new lastRSS;
        // Try to load and parse RSS file of Slashdot.org
        $rssurl = 'http://news.google.com/?output=rss';
        $rs = $rss->get($rssurl);
        if ($rs) {
            $i = rand(0,25);
            echo $title = strip_tags(htmlspecialchars_decode($rs['items'][$i]['title']."

"))."
";
            echo $description = strip_tags(htmlspecialchars_decode($rs['items'][$i]['description']))."
";
        }
        else {
            echo "Error: It's not possible to get $rssurl...";
        }
        $im->resetStep();
    }
    elseif("bdnews" == $message){
        // Create lastRSS object
        $rss = new lastRSS;
        $rssurl = 'http://rss.bdnews24.com/rss/english/home/rss.xml';
        $rs = $rss->get($rssurl);
        if ($rs) {
            $i = rand(0,25);
            echo $title = strip_tags(htmlspecialchars_decode($rs['items'][$i]['title']))."
";
            echo $description = strip_tags(htmlspecialchars_decode($rs['items'][$i]['description']))."
";
        }
        else {
            echo "Oops! Looks like Server is Busy! to get ".$rssurl." Give it a try with inews";
        }
    }
    else{
        echo "Please type help to see available commands";
        $im->resetStep();
    }
}
?>

Thanks to hasin bro for your cool wrapper class 🙂

Advertisements
Tags: , ,

35 Responses to "Create your IM bot for gtalk/jabber/aim/yahoo with imified API"

i must agree that the bot is very useful! – it’s giving me great news without browser

great work ferdous, carry on 🙂

Keep it up man…:)

Thank you all for visiting my blog. I would like to add one more feature of this API. you may use your bot to post on your blog. Things like microblogging 😉

@lenin xmpphp is a very cool and matured project 🙂

Good job ferdous bhai. I am gonna learning it from you !

Thanks Hasin bhai and you too.

hmm. its great!!.
API gives us to make interesting app.
thanks Hasin boss to create a wonderful api, also thanks to ferdous vi to implement it,
keep it up 🙂

[…] friend Ferdous has implemented the IMified API wrapper class with the lastRSS.php class. Now, I’m here to […]

С Новым Годом! Успехов во всех делах в этом году

Поздравляю автора блога и читателей С Рождеством!

spasibo vchera kak raz dumal nad dannoj temoj.

Прелестно =)

Автор, давай иШШО пиши! Очень твои посты нравятся!

Спасибо за полезную информацию!

Спасибо за статью, всегда рад почитать вас!

Умные стремятся владеть информацией, мудрые – результатом ее обработки…

Не видишь, написано русским по белому?…

Встречают по одежке, а провожают шибко грамотных…

Что у программистов быстрее всего изнашивается? – Отпечатки пальцев.)

Скромность украшает человека. Особенно когда других нет украшений.

Очень интересно! Спасибо.

Так и есть =)

суперский блог!

позитивная статья:)

хорошая статья

[…] friend Ferdous also has an example of a NEWS bot. In this example not much of the capability of the bot is shown to learn more about the IM bot read […]

Интересный материал, спасибо!

Достаточно интересная и познавательная тема

обновляйтеь чаще!

Где аргументы?

А что Вы скажете, если я возьму на себя смелость предположить, что все Ваши сообщения, не более чем выдумка?

Автору спасибо, продолжайте нас радовать!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

I am Nurul Ferdous a Zend Certified Engineer (ZCE), serving at Bangladesh Internet Press Limited (BIPL) as programmer. I am a FOSS advocate and love RnD.

Categories

Me @ LinkedIn

View Nurul Ferdous's profile on LinkedIn

My Photos @ Flickr

Blog Stats

  • 42,461 [ Vistors ]

My Twitter Updates

%d bloggers like this: