Make phone ring through webserver using Asterisk

◇◆丶佛笑我妖孽 提交于 2020-01-02 08:21:31

问题


What is the easiest way? And how can it be implemented?

I thought to something like:

  1. I request a page to the webserver
  2. Php sends to asterisk a number to dial (php and asterisk are running in the same machine)
  3. Asterisk calls the phone

or

  1. A php sip client registers to remote asterisk server
  2. Php sip client sends to asterik the number to dial
  3. Phone rings

i don't care if i can hear something, it's enough that it rings


回答1:


Call File

The easiest way is to generate a Call File. Asterisk has the feature to initiate Calls through a spool directory.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+Call+Files

Hints and Notes:

  • you have to create the call file in a seperate directory and move it (do not use copy, because asterisk parses the file immediately, but move is safe) into the spool directory.

  • The call file must be owned by the user asterisk runs as

  • asterisk (utime() on the file ) checks the modification timestamp, and schedules the call on it, if the modified timestamp is in the future

AMI - the Asterisk Manager Interface

It is also possible to initiate a Call over a Script (AMI). You have to set up a login (ie. username, password) in manager.conf. Test the AMI with Telnet at the asterisk server ip at port 5038:

Action: Login
Username: username
Secret: password

Action: Originate
Channel: SIP/123
Context: default
Exten: 012345678
Priority: 1
Callerid: AMICall

Action: Logoff

You could also use PHP-AMI (comes with PHP-AGI ) to dial out.

Secutity Note of manager.conf:

 ---------------------------- SECURITY NOTE -------------------------------
; Note that you should not enable the AMI on a public IP address. If needed,
; block this TCP port with iptables (or another FW software) and reach it
; with IPsec, SSH, or SSL vpn tunnel.  You can also make the manager
; interface available over http/https if Asterisk's http server is enabled in
; http.conf and if both "enabled" and "webenabled" are set to yes in
; this file.  Both default to no.  httptimeout provides the maximum
; timeout in seconds before a web based session is discarded.  The
; default is 60 seconds.
;

AJAM - the asynchronous Javascript Asterisk Manager

AJAM is a Webserver which you could enable and use to communicate to the Asterisk Manager Interface (AMI) over http.



来源:https://stackoverflow.com/questions/15041425/make-phone-ring-through-webserver-using-asterisk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!