Skip to content

Instantly share code, notes, and snippets.

@ricventu
Last active September 21, 2017 08:51
Show Gist options
  • Save ricventu/8e73f518bc50c8d7f995bf0ea3f68e91 to your computer and use it in GitHub Desktop.
Save ricventu/8e73f518bc50c8d7f995bf0ea3f68e91 to your computer and use it in GitHub Desktop.
Handling Asterisk Manager events from AGI script in PHP
#!/usr/bin/php -q
<?php
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'phpagi.php');
$AGI = new AGI();
$ASM = $AGI->new_AsteriskManager();
$ASM->connect();
function meetme_join($event, $parameters)
{
# code...
}
function meetme_leave($event, $parameters)
{
# code...
}
$ASM->add_event_handler('MeetmeJoin', 'meetme_join');
$ASM->add_event_handler('MeetmeLeave', 'meetme_leave');
$ASM->Events('on');
while(1) {
$ASM->wait_response();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment