1. Go to this page and download the library: Download tico/phpagi library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tico / phpagi example snippets
use Phpagi\AgiClient;
$agi = new AgiClient();
$agi->answer();
$name = $agi->getVariable('CALLERID(name)');
$agi->sayNumber(1234);
$agi->hangup();
use Phpagi\AgiClient;
use Phpagi\CallerId;
use Phpagi\ChannelState;
$agi = new AgiClient();
$agi->answer();
$status = $agi->channelStatus();
$state = ChannelState::tryFromResult($status->result);
if ($state === ChannelState::Up) {
$agi->streamFile('welcome');
$input = $agi->getData('beep', 3000, 1);
if ($input->digit() === '1') {
$agi->execDial('SIP', '100', 30000);
}
}
$cid = CallerId::parse($agi->getRequest()->callerId);
$agi->setVariable('CALLER_NAME', $cid->name);
$agi->hangup();