Jabber Integration — Is it so tough?

What is jabber:

Jabber is an initiative to produce an open source, XML-based instant messanging platform.

Jabber is an API to provide instant messaging and presence functionality independent of data exchanged between entities. The primary use of Jabber is to give existing applications instant connectivity through messaging and presence features, contact list capabilities, and back-end services that transparently enrich the available functionality.

Jabber began in early 1998 as an open source project to both enable and ease the construction of compatible IM clients.

After two years of full-time development by a large group of individuals around the world:

  • The abstraction layer and all APIs are fully implemented.
  • The XML data types are well defined
  • Clients for all major platforms and environments are available or being developed.
  • The GPL[4]/LGPL[5] licensed Jabber Server is fully functional.
  • Numerous working server-side components (transports) exist or are in public development for popular services such as ICQ, AOL IM, Microsoft Messenger, Yahoo! Messenger, IRC, SMTP, RSS (news headlines), and more.

How you work:

When I was integrated jabber I used a php class XMPPHP.

XMPPHP is the successor to Class.Jabber.PHP and it is excellent for you. Now I am describing the step how we go ahead:

Step1: If you have an existing account at a Jabber-enabled service like Google Talk you can simply log in. Otherwise create a new gtalk ID.

Step2: Download the XMPPHP

Step3: Enter the folder XMPPHP and open sendmessage_example.php

Now edit this code.

Add this line require_once ‘XMPPHP/Log.php’; before include ‘XMPPHP/XMPP.php’;

Now you set your gtalk username and password. Say your gtalk ID is-jabber.test@gmail.com and password is-test123

Now you create your connection and complete the full code:

<?php

include ‘XMPPHP/XMPP.php’;

require_once $basepath.’XMPPHP/Log.php’;

$username = “jabber.test”;

$password = “test123″;

$to = “loren@gmail.com”;

$message = “This is a test message”;

$conn = new XMPPHP_XMPP(’talk.google.com’, 5222, “$username”, “$password”, ‘xmpphp’, ‘gmail.com’, $printlog=false, $loglevel=XMPPHP_Log::LEVEL_INFO);
try {
$conn->connect();
$conn->processUntil(’session_start’);
$conn->presence();
$conn->message($to, $message);
$conn->disconnect();
} catch(XMPPHP_Exception $e) {
die($e->getMessage());
}

O yes to not use SSL/TLS encryption if available, set

$conn->use_encryption = False;
before calling
$conn->connect();

Now you can test. Enjoy jabber! :)