Mayflower Barcamp: Developing a PHP extension for Skype

At the Mayflower Barcamp a few weeks ago we had a very interesting and promising project: Develop a PHP extension for communication with Skype. Actually, this project was a merge between two projects: One was to „develop a PHP extension“ – five out of six project members never had written any PHP extension or did any PHP core development before. The other project was the Skype extension, with the goal to have a new PHP function that could send a chat message to a given Skype profile.

Fortunately, we have got some PHP extension knowhow inhouse and got a short overview about creating PHP extensions in general, about the ext_skel shell script to create an extension skeleton, the basic knowledge about the config.m4 and so on by one of our PHP core experts.

All that happened on day one. We were able to compile the basic extension after only a few hours and could start analysing the Skype API documentation. We were happy to have the API documentation all in one file (https://developer.skype.com/Docs/ApiDoc/src) b/c the network at the Barcamp was a little unstable (notice for next time: We need a *stable* Internet connection) so we could still read and navigate in the documentation while we were being offline.

Very soon it was clear that we were not only developing a specialised Skype extension but more general a PHP extension that could talk via D-Bus to any software that communicates over D-Bus. The research for D-Bus was also taking most of the time. We were even trying to get the extension running under Windows, but gave up on the messaging system there because of time pressure (although we managed to install and configure the complete compiling environment using only free and open source tools from scratch on a machine that had never compiled any C code before).

To send a message via D-Bus on Linux one has to first create a new message call:

Then a couple of parameters have to get set:

Finally, we just have to „send and block“ to send the message via D-Bus:

After that, only some additional error checking is necessary and we can close the D-Bus connection again.

The second part was Skype: After reading the Skype API documentation we saw that one has to send only a few commands via D-Bus to Skype to send a short chat message to a contact. For security reasons, Skype shows a popup box to ask the user if a particular application is allowed to access Skype (the webserver and Skype need to run under the same user id). When specifiying the first command as „NAME php“ Skype will ask the user whether „php“ is allowed to access the API. Then „PROTOCOL 2“ is chosen (which is sufficient for chat messages).

After that one just has to create a connection („CHAT CREATE profilename“) and send the message with „CHATMESSAGE chatid message“. The chatid is returned by CHAT CREATE. Finally, the D-Bus connection has to get closed and we are done:

It’s just a little bit of code, but we had to do a lot of research. If you are interested in having a look at this work, feel free to access the repository at

cvs -d :pserver:anonymous@mayflowersystem.com:/cvsroot/barcamp login
cvs -d :pserver:anonymous@mayflowersystem.com:/cvsroot/barcamp checkout skype

Für neue Blogupdates anmelden:


11 Gedanken zu “Mayflower Barcamp: Developing a PHP extension for Skype

    • Hi Yoshi, we’ve moved the server with the repository, the PHP extension for Skype should now be reachable here:

      cvs -d :pserver:anonymous@mayflowersystem.com:/cvsroot/barcamp login
      cvs -d :pserver:anonymous@mayflowersystem.com:/cvsroot/barcamp checkout skype

      • Can’t checkout the SVN repository.

        $ cvs -d :pserver:anonymous@mayflowersystem.com:/cvsroot/barcamp login
        Logging in to :pserver:anonymous@mayflowersystem.com:2401:/cvsroot/barcamp
        CVS Password:
        cvs [login aborted]: cvs pserver: cannot open /cvsroot/barcamp/CVSROOT/config: Not a directory

  1. i got this error while compiling..

    checking if nawk is broken… no
    checking for skype support… yes, shared
    ./configure: line 3883: SEARCH_FOR: command not found
    checking johannfor skype files in default path… found in /usr
    checking for dbus_connection_open in -ldbus-1… no
    configure: error: wrong skype lib version or lib not found

  2. got it working… but im receiving this message

    Warning: Mitteilung: CHATMESSAGE #yoshix86/$josephine.napari;10cc836e02bc4ff1 HELLLO in /home/aqlx86/www-dev/skype2/test.php on line 7
    ALERT – canary mismatch on efree() – heap overflow detected (attacker ‚REMOTE_ADDR not set‘, file ‚/home/aqlx86/www-dev/skype2/test.php‘, line 7)

  3. is there a solution? is it because of the Suhosin-Patch?

    PHP 5.2.4-2ubuntu5.1 with Suhosin-Patch 0.9.6.2 (cli) (built: May 9 2008 16:34:16)
    Copyright (c) 1997-2007 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

  4. Leider benötigt man immer noch ein X-Windows um Skype überhaupt fahren zu können.
    Schade, so fallen Serverapplikationen aus, und die wären ja eigentlich am interessantesten.
    Skype auf einem Linux unter der Konsole laufen zum laufen zu kriegen wäre auch mal spannend.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.