[Asterisk-Dev] Show incoming number via jabber

-mat- filid brandy asterisk-dev at linuxpinguin.de
Tue Mar 1 16:24:34 MST 2005


Hi et al,

I wrote the following PHP script to send a message via the jabber IM
service to inform about an incoming call.

To get it running you need:
- php	(http://www.php.net)
- pear	(http://pear.php.net)
- class.jabber.php (http://cjphp.netflint.net/)

To use it in extensions.conf:

exten => s,1,AGI,jabber.php ; Notify via jabber
exten => s,n,Wait,30        ; Wait thirty second
exten => s,n,Answer         ; Answer the line
...

Have fun,
~ -mat-

--( jabber.php START )------------------------------------
#!/usr/bin/php -q
<?php
~        //error_reporting(E_ALL);
~        ini_set('display_errors', 0 );
~        ini_set('include_path', '.:/usr/share/pear');
~        require_once('class.jabber.php');

~        ob_implicit_flush(true);
~        set_time_limit(0);

~        $err=fopen("php://stderr","w");
~        $in = fopen("php://stdin","r");
~        while (!feof($in)) {
~                $temp = str_replace("\n","",fgets($in,4096));
~                $s = split(":",$temp);
~                $agi[str_replace("agi_","",$s[0])] = trim($s[1]);
~                if (($temp == "") || ($temp == "\n")) {
~                        break;
~                }
~        }

~        $JABBER = new Jabber;

~        $JABBER->server   = 'jabber.de.cw.net';
~        $JABBER->port     = 5222;
~        $JABBER->username = 'asterisk';
~        $JABBER->password = 'xxxx';
~        $JABBER->resource = 'ClassJabberPHP';

~        $JABBER->Connect() or die('Could not connect!');
~        $JABBER->SendAuth() or die('Could not authenticate!');

~        $JABBER->SendPresence(NULL,NULL,'online');

~        $JABBER->SendMessage('xxx at jabber.de.cw.net', 'chat', NULL,
array( 'body' => 'Anruf von '.$agi['callerid'].' an '.$agi['dnid'] ));
~        $JABBER->Disconnect();
~        fclose($in);
~        fclose($err);
?>
--( jabber.php STOP )------------------------------------------



More information about the asterisk-dev mailing list