Example #1
0
<?php

require_once 'PhpSIP.class.php';
/* Sends NOTIFY to reset Linksys phone */
try {
    $api = new PhpSIP();
    $api->setUsername('10000');
    // authentication username
    $api->setPassword('secret');
    // authentication password
    // $api->setProxy('some_ip_here');
    $api->addHeader('Event: resync');
    $api->setMethod('NOTIFY');
    $api->setFrom('sip:10000@sip.domain.com');
    $api->setUri('sip:10000@sip.domain.com');
    $res = $api->send();
    echo "response: {$res}\n";
} catch (Exception $e) {
    echo $e;
}
Example #2
0
<?php

require_once 'PhpSIP.class.php';
/* Sends test message */
$item = $_GET['proxy'];
$item = $_GET['method'];
$item = $_GET['to'];
$item = $_GET['from'];
try {
    $api = new PhpSIP();
    $api->setProxy('sip.host.ext:5060');
    $api->addHeader('Event: Homer');
    $api->setMethod('OPTIONS');
    $api->setFrom('sip:1234@host.ext');
    $api->setUri('sip:1234@host.ext');
    $api->setUserAgent('HOMER SIPCAPTURE');
    $res = $api->send();
    echo "response: {$res}\n";
} catch (Exception $e) {
    echo $e;
}
 public function actionCall2()
 {
     try {
         $api = new PhpSIP();
         // IP we will bind to
         $api->setUsername('118338');
         // authentication username
         $api->setPassword('55XI8N');
         // authentication password
         $api->setProxy('202.153.128.34');
         $api->addHeader('Event: resync');
         $api->setMethod('NOTIFY');
         $api->setFrom('sip:118338@voiprakyat.or.id');
         $api->setUri('sip:118339@voiprakyat.or.id');
         $res = $api->send();
         echo "res1: {$res}\n";
     } catch (Exception $e) {
         echo $e->getMessage() . "\n";
     }
 }
Example #4
0
function phpSip()
{
    require_once 'php-sip/PhpSIP.class.php';
    $phpsip_to = getVar('to', NULL, $_REQUEST, 'string');
    $phpsip_from = getVar('from', NULL, $_REQUEST, 'string');
    $phpsip_prox = getVar('proxy', NULL, $_REQUEST, 'string');
    $phpsip_meth = getVar('method', NULL, $_REQUEST, 'string');
    $phpsip_head = getVar('head', NULL, $_REQUEST, 'string');
    echo "FROM: " . $phpsip_from . "<br>TO: " . $phpsip_to . "<br>VIA " . $phpsip_prox . "<br>METHOD: " . $phpsip_meth . "<br>HEAD: " . $phpsip_head . "<br>";
    echo "<br>";
    /* Sends test message */
    try {
        $api = new PhpSIP();
        $api->setProxy('' . $phpsip_prox);
        $api->addHeader('X-Capture: ' . $phpsip_head);
        $api->setMethod('' . $phpsip_meth);
        $api->setFrom("sip:" . $phpsip_from);
        $api->setUri("sip:" . $phpsip_to);
        $api->setUserAgent('HOMER/Php-Sip');
        $res = $api->send();
        echo "SIP response: {$res}\n";
    } catch (Exception $e) {
        echo $e;
    }
}
Example #5
0
function sip_func($method, $host)
{
    require_once 'phpsip.class.php';
    try {
        $api = new PhpSIP();
        //      $api->setUsername('10000'); // authentication username
        //      $api->setPassword('secret'); // authentication password
        //      $api->setProxy('some_ip_here');. // set proxy
        //      $api->addHeader('Options: ping');
        $api->setMethod($method);
        $api->setFrom('sip:1@' . $host);
        $api->setUri('sip:1@' . $host);
        $res = $api->send();
        //      echo "response: $res\n";
    } catch (Exception $e) {
        do_log("Check sip connection response error: " . $e, false, 'problem', __FILE__, __LINE__, $offlog);
    }
    do_log("Check sip connection response: " . $res, 'd', 'info', __FILE__, __LINE__, $offlog);
    return $res;
}
Example #6
0
 function _call($params)
 {
     $user = $params['user'];
     $mysip = self::get_sip_info($user->id);
     $user_to = PresenceController::_userstr($params['callee']);
     if ($user_to) {
         // They want to call another user, so grab SIP data for target user.
         $sip = self::get_sip_info($user_to->id);
         $to = 'sip:' . $sip->ext . '@' . $sip->domain;
     } elseif (preg_match('/^[-0-9]+$/', $params['callee'])) {
         // Valid dial string.
         $to = 'sip:' . $params['callee'] . '@' . $mysip->domain;
     } else {
         // Invalid!
         self::notify($user, 'You can call a chat user or a phone number (only numbers or dashes).');
     }
     if (isset($to)) {
         // MAKE THE CALL!
         try {
             include 'php-sip/PhpSIP.class.php';
             $from = "sip:{$mysip->ext}@{$mysip->domain}";
             $api = new PhpSIP();
             $agent = "sip:{$mysip->user}@{$mysip->domain}";
             $api->setUsername($mysip->user);
             $api->setPassword($mysip->pass);
             // First get the initiator on the line.
             self::notify($user, "Calling you first...");
             $api->setMethod('INVITE');
             $api->setFrom($agent);
             $api->setUri($from);
             switch ($api->send()) {
                 case 200:
                     // Initiator answered, so now we ring the other guy.
                     if ($user_to) {
                         self::notify($user_to, ($user->nickname ? $user->nickname : $user->name) . ' is calling you!');
                     }
                     $api->setMethod('REFER');
                     $api->addHeader("Refer-to: {$to}");
                     $api->addHeader("Referred-By: {$agent}");
                     $api->send();
                     // Let those guys talk, get out of dodge.
                     $api->setMethod('BYE');
                     $api->send();
                     $api->listen('NOTIFY');
                     $api->reply(481, 'Call Leg/Transaction Does Not Exist');
                     break;
                 default:
                     self::notify($user, "You didn't answer!");
             }
         } catch (Exception $e) {
             try {
                 $api->setMethod('CANCEL');
                 $api->send();
                 self::notify($user, 'Error placing call!');
             } catch (Exception $e) {
                 self::notify($user, 'Error placing call, and another error cleaning up!');
             }
         }
     }
     return true;
 }