Пытаюсь подключиться к sipnet.ru и сделать звонок через этот код:
<?php
try{
$username = '';
$password = '';
$server = 'sipnet.ru';
require_once('PhpSIP.class.php');
$api = new PhpSIP();
$to = '+123123123';
$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->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."'}\n";
} catch (Exception $e) {
echo "{'error':'true', 'text':'".$e."'}\n";
}
?>
Но сразу выдает ошибку 401, то есть не получается авторизоваться
Логин и пароль вводу правильно, т.к. с приложения linphone всё работает с теми же данными