How to get dzone feeds as IM using JAXL? Add

How to get dzone feeds as IM using JAXL? Add [email protected]

The most funny part of knowing XMPP protocol is that you can execute all your daily web needs using it. Be it playing anagram online or achieving your status messages. And your life gets easy if you are using an XMPP Client Library like JAXL.

Here I have tried to create a simple bot which allows you to read newest links posted on dzone category wise. Simply add [email protected] in your gtalk messenger and start by typing options.

Available options are:

  • frontpage: Will send you latest links on frontpage.
  • queue: Will send you latest links in queue.
  • tag: Send in a tag e.g. php,java,xml and you will get latest links for the particular tag

Here is modified eventMessage() method of JAXL library powering [email protected]:

    function eventMessage($fromJid, $content, $offline = FALSE) {

      // If the message is not an offliner
      if(!$offline) {
        if($this->restrictJid && !in_array($this->getBareJid($fromJid),$this->authorizedJid)) { // Block un-authorized users
          $this->logger->logger($fromJid." tried using this service by sending:n".$content);
          $message = 'You are not authorized to use this service';
          return TRUE;
        else {
          $content = strtolower(trim($content));

          // Build RSS Feed URL depending upon passed IM
          if($content == "options") {
            $message = "Available options are:n";
            $message .= "*1. frontpage:* Will send you latest links on frontpage.n";
            $message .= "*2. queue:* Will send you latest links in queue.n";
            $message .= "*3. tag:* Send in a tag e.g. php,java,xml and you will get latest links for the particular tagn";
            return TRUE;
          else if($content == "frontpage") $url = "";
          else if($content == "queue") $url = "";
          else $url = "".$content."/rss.xml";

          // Generate cache file location
          $cache_file = "cache/dzone/".md5($url)."-".$content.".rss";

          // If cache file is not older than 900 seconds (15 min)
          if(file_exists($cache_file) && (filemtime($cache_file) > time() - 900)) {
            $this->logger->logger("RSS already found cached...");
          else { // else fetch a fresh copy of RSS
            $this->logger->logger("Fetching RSS for url:n".$url);
            $head = $this->fetchWebURL($url);
            if($head['errno'] == 0 && $head['http_code'] == 200) {
              $this->logger->logger("Fetched successfully...");
              $data = $head['content'];
              $fh = fopen($cache_file,"w");
            else {
              // Send a message saying no such feed exists
              $this->logger->logger("Failed to fetch the RSS feed...");
              $message = 'No feed exists for the passed keyword: '.$content;
              return TRUE;

          // Parse RSS Feed
          $r = &new XML_RSS($cache_file);
          $NumberOfFeeds = count($r->getItems());
          if($NumberOfFeeds > 0) {
            $message = '';
            foreach($r->getItems() as $key => $item) {
              if($this->count < $this->maxResults) {
                $message .= "*".$item["title"]."*n";
                $message .= $item["link"]."n";
                $message .= $item["description"]."nn";
              else {
            $message .= "powered by *Jaxl*"."nn";
            $this->count = 0;
            return TRUE;
          else {
            // Send a message saying no feed found
            $message = 'No feed was found for passed keyword: '.$content;
            return TRUE;
      else {
        // Send an appropriate message
        $this->logger->logger($fromJid." sent an offliner saying:n".$content);
        return TRUE;

To run this sample application you need:

  • JAXL Library (
  • XML_RSS Package (pear install XML_RSS)
  • Create a directory cache/dzone where this application will cache all rss files
  • Include jaxl4dzone.class.php in index.php, instead of jaxl.class.php and run ‘php index.php’ from command line to start this application

Checkout the complete code and JAXL library from

Now browse new links even when dzone is down for maintenance 😛
Do let me know about your feedbacks 🙂


  1. namespace

    Wow! This is great, and you are true. I am getting a lot of down for maintenance message from dzone since past few days. And if this works even if its down, you simply rock for me.

  2. Very very cool. Just a note about the downtime, we moved to a new datacenter this past week and we’ve been experiencing some nasty DNS issues. We hope these are going to be resolved by the end of the week and that you’re going to see some great new speed and some new features coming up in the near future.

    DZone, Inc.

  3. Gaurav


    I have some to doubts regarding creating my own bot using JAXL. The doubts are as follows:

    I have downloaded the code from
    I have done the changes in the config.php file. But where I should keep the files
    How can I get & link the bot id with the server pages?
    I am trying “prod” environment. I have uploaded files on server.
    How to proceed?
    Pls help me.

    Thanks in advance.

  4. You need to do the following stuff:

    1. Checkout the whole code from Note that jaxl4dzone.class.php doesn’t comes by default with the .rar file under featured downloads. So u need to check out that code.
    2. You put the following files in a single directory: config.ini.php, xml.class.php, index.php, xmpp.class.php, jaxl4dzone.class.php, logger.class.php. Also create a directory named log, which have a file logger.log inside it.
    3. Open config.ini.php and set $env = “prod” and enter your gmail specifications under prod section.
    4. Open index.php and change the line include_once(“jaxl.class.php”) to include_once(“jaxl4dzone.class.php”)
    5. If you are on windows, open command line and point it to the directory where all these files are.
    6. Run from command line: php index.php
    7. If you are on linux, point to this directory and run the command in line (6) above.

    I hope i haven’t missed out anything. Run the above procedure and do mail me the log files, if it doesn’t work for you. That will help me identify the exact problem.

  5. Pingback: Programatically control your google mails using JAXL v 1.0.4 « Abhi’s Weblog

  6. Pingback: 5 exciting (gaming) bots you can create using Jaxl (Jabber XMPP Library) in PHP | Abhi's Weblog

  7. Pingback: Get lyrics for any song using XMPP and PHP right into your IM – Add [email protected] | Abhi's Weblog

Comments are closed.