text
stringlengths
0
152
|
Chapter 17: Asterisk Manager Interface and Call Files
/manager (/amanager) encoding
The manager encoding type provides a response in simple HTML form. This interface
is primarily useful for experimenting with the AMI:
$ curl -v "http://localhost:8088/manager?action=login&username=hello&secret=world"
$ curl -v --digest -u hello:world http://localhost:8088/amanager?action=ping
/mxml (/amxml) encoding
The mxml encoding type provides responses to manager actions encoded in XML:
$ curl -v "http://localhost:8088/mxml?action=login&username=hello&secret=world"
$ curl -v --digest -u hello:world http://localhost:8088/amxml?action=ping
Manager events
When connected to the native TCP interface for the AMI, manager events are deliv‐
ered asynchronously. When using the AMI over HTTP, you must retrieve events by
polling for them. You retrieve events over HTTP by executing the WaitEvent man‐
ager action. The following example shows how events can be retrieved using the
WaitEvent manager action. The steps are:
1. Start an HTTP AMI session using the Login action.
2. Register a SIP phone to Asterisk to generate a manager event.
3. Retrieve the manager event using the WaitEvent action.
The interaction looks like this:
$ wget --save-cookies cookies.txt \
> "http://localhost:8088/mxml?action=login&username=hello&secret=world" -O -
<ajax-response>
<response type='object' id='unknown'>
<generic response='Success' message='Authentication accepted' />
</response>
</ajax-response>
$ wget --load-cookies cookies.txt \
< "http://localhost:8088/mxml?action=waitevent" -O -
<ajax-response>
<response type='object' id='unknown'>
<generic response='Success' message='Waiting for Event completed.' />
</response>
<response type='object' id='unknown'>
<generic event='PeerStatus' privilege='system,all'
channeltype='SIP' peer='SIP/0000FFFF0004'
peerstatus='Registered' address='172.16.0.160:5060' />
</response>
<response type='object' id='unknown'>
Protocol Overview
|
309
<generic event='WaitEventComplete' />
</response>
</ajax-response>
You’ll need to develop mechanisms in your application to ensure that buffered events
are frequently polled.
Example Usage
Most of this chapter so far discussed the concepts and configuration related to the
AMI. This section will provide some example usage.
Originating a Call
The AMI has the Originate manager action that can be used to originate a call. Many
of the accepted headers are the same as the options placed in call files. Table 17-1 lists
the headers accepted by the Originate action.
Table 17-1. Headers for the Originate action
Option
ActionID
Example value
a3a58876-
f7c9-4c28-
aa97-50d8166f658d
Channel
SIP/myphone
Context
default
Exten