Internaly GoogleTalk uses XMPP messaging protocol. XMPP - The Extensible Messaging and Presence Protocol. Often also called as Jabber. Since it’s an open protocol means it’s possible to develop your own clients to connect to other XMPP servers.
There are quite a few xmpp libraries that provide client functionality. The one I tried myself is XMPPHP. It’s usage is really simple. For example to send a message you would do something like this:
require_once('XMPPHP/XMPP.php');
$conn = new XMPPHP_XMPP('talk.google.com', 5222, 'user@gmail.com',
'password', 'xmpphp', 'gmail.com', $printlog = false,
$loglevel = XMPPHP_Log::LEVEL_INFO);
try {
$conn->connect();
$conn->processUntil('session_start');
$conn->presence();
$conn->message('friend@gmail.com', 'Hi!');
$conn->disconnect();
} catch(XMPPHP_Exception $e) {
die($e->getMessage());
}
I find this to be quite valuable. Who these days does not keep their IM live all the time? I imagine it’s like a cellphone. Meaning you can use it for many different services.
For example I developed a small application that checks if every one of my collegues is “Working on a task” in FogBugz and if not it sends an automated message to them to remind them that they should select a task they are working on. I also have a small tracker that tracks a local torrents network looking for high rated IMDB movies. I have an idea that it would be nice to integrate my tracker with GTalk so that it would inform me when a new episode of House MD is available or a new highly rated movie appears. The sky is the limit
6 Comments for Google Talk XMPP Jabber integration with PHP
Balan | January 17, 2010 at 6:47 AM
Balan | January 17, 2010 at 6:49 AM
Any hosting problem? Please help me
Widyo Harsono | June 13, 2010 at 4:15 PM
i ve got lot of this error messege when trying sending IM to gtalk using XMPPHP, but i think theres no hosting problem. can everybody tell me what is this and help me how to avoid it printed to screen? thx
Deprecated: Function split() is deprecated in C:\wamp\www\XMPPHP\XMLStream.php on line 266
Deprecated: Function split() is deprecated in C:\wamp\www\XMPPHP\Roster.php on line 121
Warning: fclose() expects parameter 1 to be resource, null given in C:\wamp\www\XMPPHP\XMLStream.php on line 403


I am getting “Could not connect before timeout.” error