Location: PHPKode > projects > ICTFAX > ictfax/agi-bin/sendsms.php
#!/usr/bin/php -q
<?php
    require_once dirname(__FILE__)  . '/phpagi/phpagi.php';

    global $argv;
    $stdinRequest = array();
    $pages = 1;

    //Getting input data (Parameter Passed to Script)
    $smsCid  = $argv[1];

    //creating PHPAGI instance and getting dialplan status
    $agi = new AGI();
    $stdinRequest = $agi->request;

    $agi->exec('SMS',array($smsCid,'ap1'));

    foreach (glob("$smsCid.*") as $filename) {
        if (is_file($filename)) {
            $pages = 0;
        }
    }
    if ($pages > 0) {
        $smsStatus = 0;
        $smsStatusString = "SMS Sent";
    } else {
        $smsStatus = 99;
        $smsStatusString = "Unkown error: can not deliver sms";
    }

    //sending output to asterisk
    $agi->database_put('SMS_'.$smsCid, 'SMSPAGES', $pages);
    $agi->verbose('Sms Pages  : ' . $pages, 1);
    $agi->database_put('SMS_'.$smsCid, 'STATUS', $smsStatus);
    $agi->verbose('Sms Status : ' . $smsStatus, 1);
    $agi->database_put('SMS_'.$smsCid, 'STATUSSTRING', $smsStatusString);
    $agi->verbose('Sms Result : ' . $smsStatusString, 1);
?>
Return current item: ICTFAX