How to Send an ICQ Message With PHP Script

By | February 3, 2010

Today I will show you how to send ICQ messages using PHP. We will need a class, named Webicqlite. You can download it and rename to WebIcqLite.class.php.

Sending ICQ messages never been so easy with this class. In order to test it, we will need login and password for ICQ, if you don’t have it, you can obtain it at ICQ.

Here comes the code listing:

<?php
// Let’s connect our main class
include(‘WebIcqLite.class.php’);
// replace 111111111 with your ICQ UIN
define(‘UIN’, 111111111);
// Put your ICQ password
define(‘PASSWORD’, ‘password’);
// Creating an object
$icq = new WebIcqLite();
// Trying to connect to ICQ server
if($icq->connect(UIN, PASSWORD)){
// Trying to send a message to 123456789 (replace with your desired destination number)
if(!$icq->send_message(‘123456789’, ‘Hello from php!!!’)){

echo $icq->error;

}else{

echo ‘Message sent’;

}

$icq->disconnect();

}else{

echo $icq->error;

}

?>

Everything seems to be simple. I am using it to notify myself about server events, like server overload, scheduled backup, etc. It is just a single feature of this class, I will post more solutions a bit later. If you need any specific solution, please, let me know.