Answer the question
In order to leave comments, you need to log in
How to choose which number to call PHPsip from?
The code is written in the PHPsip library, it calls the number specified in the $to variable.
So how do you choose the number to call from?
<?php
try{
$username = 'логин';
$password = 'пароль';
$server = 'sip.qwerty.ui';
$to = '+79000000000'; //куда звонить
require_once('PhpSIP.class.php');
$api = new PhpSIP();
$api->setUsername($username);
$api->setPassword($password);
$api->addHeader('Subject: click2call');
$api->setMethod('INVITE');
$api->setFrom('sip:'.$username.'@'.$server);
$api->setUri('sip:'.$to.'@'.$server);
$res = $api->send();
if ($res == 200) {
$api->setMethod('REFER');
$api->addHeader('Refer-to: '.$to);
$api->addHeader('Referred-By: sip:[email protected]'.$api->getSrcIp());
$api->send();
//echo "SUCCESS CALL";
$api->setMethod('BYE');
$api->send();
$api->listen('NOTIFY');
$api->reply(481,'Call Leg/Transaction Does Not Exist');
}
while ($res == 'No final response in 5 seconds.') {
$api->setMethod('CANCEL');
$res = $api->send();
echo "{'warning':'No final response in 5 seconds.'}";
}
echo "{'result':'".$res."'}";
} catch (Exception $e) {
echo "{'error':'true', 'text':'".$e."'}";
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question