Page 279 - Asterisk™: The Future of Telephony
P. 279
http://localhost:8088/asterisk/static/ajamdemo.html
If for some reason you’re having problems getting to that demo page, go back to the
asterisk-gui source code directory and run:
# make checkconfig
And that’s it! Asterisk is now web-enabled. Now, let’s move on to the actual work of
developing with the Asterisk GUI.
Developing for the Asterisk GUI
Once you’ve installed the files for the Asterisk GUI, you can begin to play with devel-
oping for the GUI. Over the next few sections, we’ll walk through setting up the various
components and putting them together to enhance and expand the capabilities of the
GUI.
Issuing Manager Commands over HTTP
The Asterisk GUI issues commands to Asterisk by calling specially crafted URLs to the
Asterisk web server. This section provides examples of some commonly used com-
mands (actions) and the corresponding web server responses. These AMI URLs have
the following general structure:
http://hostname:8088/asterisk/rawman?action=command&....parameter=value pairs...
http://hostname:8088/asterisk/manager?action=command&....parameter=value pairs...
http://hostname:8088/asterisk/mxml?action=command&....parameter=value pairs...
The difference between the rawman, manager and mxml URLs is important. The web server
exports three different views of the AMI interface. If you use a rawman URL, the server
returns a series of keyword/value pairs in the HTTP response. If you use a manager URL,
the server returns the result formatted as HTML. In a similar style, if you use a mxml
URL, the server returns the results formatted in XML. For modern Ajax-style applica-
tions, the rawman and mxml forms are probably more useful. §
The actions that can be sent to the server, along with their parameters, are the ordinary
manager commands described in Appendix F. Note that the LOGIN and CHALLENGE ac-
tions are unique in that they aren’t sent to Asterisk itself, but are processed by the
Manager interface to authenticate the user. If the user hasn’t authenticated correctly,
the server returns an error response rather than sending the action to Asterisk for pro-
cessing.
Let’s look at some commonly used actions, and see how we can use them to control
the server.
§ By similar reasoning, the manager form is much easier for humans to use for debugging purposes.
Developing for the Asterisk GUI | 251