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

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

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 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() {
      print "Setting Status...n";
      print "Donen";

      foreach($this->rosterList as $buddy) {
        print "Sending message to ".$buddy."n";
        $this->sendMessage($buddy,"Message broadcasted using *JAXL Library*");

      /* Now loggout of the system */

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


Other JAXL Extensions you may want to checkout:

Happy Broadcasting!


  1. 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 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

  2. 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.

  3. 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,
    1. Pingback: Twitter Trackbacks for How to broadcast a message to your Gtalk friends using JAXL? | Abhi's Weblog [] on

  4. Pankaj

    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
    class JAXL extends XMPP {
    function setStatus() {
    print “Setting Status…n”;
    print “Donen”;

    foreach($this->rosterList as $buddy) {
    print “Sending message to “.$buddy.”n”;
    $this->sendMessage($buddy,”Message broadcasted using *JAXL Library*“);

    /* Now loggout of the system */


    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


  5. Pankaj

    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

    1. Pingback: uberVU - social comments

Comments are closed.