libpurple php binding

Anatoliy Belsky anatoliy at
Tue Nov 27 18:05:38 EST 2007

Hi there,

so I would present the begin of my work on the libpurple php binding. It's yet 
very rudimentary but I've already realized the nullclient and a little bit 

The project site can be found on:

The code itself can be fetched with;

	svn co phpurple

The further steps would be (don't forget to install the php devel package on 
your system):

cd phpurple
./configure --enable-purple

After this you should have the modules/ file. And you can use it.
Eventually you can run

make install 

if you have root rights and want to install it globally as a php extension 
(but it's not nesessary yet).

than make the file test.php (in the phpurple dir) with the following content:


if(!extension_loaded('purple')) {
        dl('purple.' . PHP_SHLIB_SUFFIX);

$ui_id = "hello world";

function my_write_conv($conversation, $who, $alias, $message, $flags, $time)
        if ($alias) {
                $name = $alias;
        } else if ($who) {
                $name = $who;
        } else {
                $name = NULL;

        if(PURPLE_MESSAGE_RECV == $flags) {
                printf( "(%s) %s %s: %s\n",
                                date("H:i:s", $time),

if(!purple_core_init($ui_id)) {
        die("libpurple initialization failed\n");


//or some protocol ever supported
$account = purple_account_new("somenick at", "MSN");
purple_account_set_password($account, "somepass");
purple_account_set_enabled($account, $ui_id, true);

purple_savedstatus_new(NULL, PURPLE_STATUS_AVAILABLE);




Now you should be able to start a conversation from the other side and see the 
outputs in the console. To run the php ( I expect u still in the phpurple 
dir ) run

php -n -d extension_dir=modules  -f test.php 

I've tested and built the whole thing on debian etch with PHP 5.2.0-8

So if someone has tested this, I would hear something, what should be it the 
ext, to can call it something like phpurple1.0 ... may be you see something 
wrong in my c code ... I'll assume any meaning

thanks a lot


More information about the Devel mailing list