How to broadcast a message to your Gtalk friends using JAXL?

Standard

In this era of social media we all look forward to easy and utility tools to easily market our site and blogs. In this post I will demonstrate a ready to use script, which will help you broadcast your message to everyone on your gtalk friend list in one go.

jaxl4broadcast.class.php
jaxl4broadcast.class.php is an extension of JAXL library. This extension simply saves all your buddy list in an array while connecting with Gtalk servers, and then send out your custom message to all of them in one go. The code that will do the task:

    function setStatus() {
      $this->sendStatus($this->status);
      print "Setting Status...\n";
      print "Done\n";

      foreach($this->rosterList as $buddy) {
        print "Sending message to ".$buddy."\n";
        $this->sendMessage($buddy,"Message broadcasted using *JAXL Library http://code.google.com/p/jaxl*");
        sleep(1);
      }

      /* Now loggout of the system */
      exit;
    }

PS: You need to checkout the latest version of xmpp.class.php for jaxl4broadcast.class.php to work. jaxl-1.0.4 doesn’t include the latest checked in xmpp.class.php

Using jaxl4broadcast.class.php

  • Checkout the latest version of JAXL library from here
  • Open config.ini.php, replace myproductionuser => gmail id and password => gmail password
  • Open index.php, replace jaxl.class.php => jaxl4broadcast.class.php
  • Open command line window (for windows) and shell prompt (for *nix). Navigate to the checked out directory
  • From command prompt run php index.php
  • If everything goes alright, you will see something like the image below
  • See list of known issues if you are new to JAXL and having trouble

jaxl4broadcast

Other JAXL Extensions you may want to checkout:

Happy Broadcasting!

  • Samsonsa

    Very nice utility script.
    Thanks for sharing the same.

  • bruce

    i love it, but doens’t work for me,
    it hangs on ‘Starting TLS Encyption’

  • http://abhinavsingh.com admin

    Hi Bruce, This is quite unexpected. Though I would like you to check with one of the known bug and its fix here: PHP Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto http://code.google.com/p/jaxl/issues/detail?id=3 Here is what I did just now and it worked for me: 1. Checked out the code from googlecode repository 2. Opened config.ini.php and entered my gmail username and password 3. Opened index.php, and replaced jaxl.class.php with jaxl4broadcast.class.php 4. Runned “php index.php” from command line and the system worked. Kindly let me know if it doesn’t work for you, after reading the fix from the above issue. Regards, -Abhi

  • bruce

    i’ve added a new issue … #7, stream_socket_enable_crypto seems to fail in some circumstances using TLS …

    i’m running on linux, but this shouldn’t matter at all, I notice someone else on google groups seemed to have the same issue.

  • http://abhinavsingh.com admin

    Just to confirm, you got it working for you right?

    Also thanks for pointing this out, I will add it in the list of known issues, until I push the required changes in next release.
    Thanks again,
    -Abhi
  • bruce

    correct, the fix i posted worked for me

    thanks, great work

  • Pingback: Twitter Trackbacks for How to broadcast a message to your Gtalk friends using JAXL? | Abhi's Weblog [abhinavsingh.com] on Topsy.com()

  • Pankaj

    Hi,
    Thanks for sharing your work. I am facing a problem. I am getting this error:
    Warning: Invalid argument supplied for foreach() in /var/www/news/jaxl4broadcast.class.php on line 9
    My jaxl4broadcast.class.php includes this
    include_once(“xmpp.class.php”);
    class JAXL extends XMPP {
    function setStatus() {
    $this->sendStatus($this->status);
    print “Setting Status…\n”;
    print “Done\n”;

    foreach($this->rosterList as $buddy) {
    print “Sending message to “.$buddy.”\n”;
    $this->sendMessage($buddy,”Message broadcasted using *JAXL Library http://code.google.com/p/jaxl*“);
    sleep(1);
    }

    /* Now loggout of the system */
    exit;
    }

    }

    I have downloaded jaxl-1.0.4  and made the necessary changes in the file as told by you.
    I am using xmpp.class.php included in the jaxl folder.May be due to this its not working.If this is the reason from where can i get this file?
    Please help
    Thanks
     

     
     
     
     
    Regar

  • http://abhinavsingh.com admin

    the error mesage means probably $this->rosterList have no items in it. Does the account you are trying to test with, have any friends added to it?

    xmpp.class.php and other files come bundled with jaxl distribution. You can download the same from here: http://jaxl.googlecode.com/files/jaxl-1.0.4.rar

  • http://abhinavsingh.com admin

    here you have link to the xmpp class supporting broadcast:

    http://code.google.com/p/jaxl/source/browse/trunk/xmpp.class.php

    Hope this helps you.

    • http://yahoo aneelkumar

      hi Abi,
      can i broad cast mp3 song by setting it as custom message.

  • Pankaj

    HI,
    Thanks for your suggestion replacing the xmpp.class.php bundled with jaxl-1.0.4 with the new xmpp.class.php as specified in the link resolved the issue. Now the code is working
    I want to ask you something
    I have created a chat room in openfire admin console.
    I want to know that how can we enable it ?
    Please guide me
    Thanks
     
     

  • Pingback: uberVU - social comments()

  • http://abhinavsingh.com Abhinav Singh

    Announcing Jaxl v3.x – asynchronous, non-blocking I/O, event based PHP client/server library – http://abhinavsingh.com/blog/2012/07/announcing-jaxl-v3-x-asynchronous-non-blocking-io-event-based-php-clientserver-library/