PHP Chat Bot: Google Talk

14,273

Solution 1

The xmpphp library should help you. Have a look at the examples.

PHP is absolutely the last language I would use for something like this (well, okay, I wouldn't do it in awk or sed either), but if you're set on using it, you can.

Solution 2

Give a look to this library:

Gives you a fully OOP API (> PHP5) to communicate using this protocol.

By default it uses TLS so you will not have any problems connecting to the talk google server.

Check this code example:

<?php
include("xmpp.php");
$conn = new XMPP('talk.google.com', 5222, 'username', 'password', 'xmpphp',
                 'gmail.com', $printlog=False, $loglevel=LOGGING_INFO);
$conn->connect();
$conn->processUntil('session_start');
$conn->message('[email protected]', 'This is a test message!');
$conn->disconnect();
?>
Share:
14,273
Cyclone
Author by

Cyclone

I'm a php web developer. I'm mostly done with my secret project. Hold out just a bit longer! I keep getting distracted by various things, like Project Euler, but at least it's entertaining. When in doubt, Fnord!

Updated on June 04, 2022

Comments

  • Cyclone
    Cyclone about 2 years

    I was wondering how to create a chat bot for Google Talk via special client.

    I know it uses XMPP to send messages, but I do not know how to use this at all. It is my understanding that I should be able to make a bot which chats for me when I am away if I were to create my own client page, which would parse the chats with my data. Where would I begin if I wanted to create a custom client, and how could I make it parse messages and autorespond in a set manner? My intended usage: autoresponder for when I am AFK, with a decent AI (which I can make.)

    Can I use this protocol with PHP to make my bot, or must it be java or python based?

    Thanks for any and all help!!!