On Level 7 Systems' blog they show how to implement click-to-call functionality
triggered from a web page - in a relatively simple PHP script.
$api = new PhpSIP();
$api->setDebug(true);
$api->addHeader('Subject: click2call');
$api->setMethod('INVITE');
$api->setFrom('sip:c2c@'.$api->getSrcIp());
$api->setUri($from);
$res = $api->send();
if ($res == 200)
{
$api->setMethod('REFER');
$api->addHeader('Refer-to: '.$to);
$api->addHeader('Referred-By: sip:c2c@'.$api->getSrcIp());
$api->send();
$api->setMethod('BYE');
$api->send();
$api->listen('NOTIFY');
$api->reply(481,'Call Leg/Transaction Does Not Exist');
}
Check it out the full application here:
Click to Call with PHP-SIP
No comments:
Post a Comment