问题
What is the easiest way? And how can it be implemented?
I thought to something like:
- I request a page to the webserver
- Php sends to asterisk a number to dial (php and asterisk are running in the same machine)
- Asterisk calls the phone
or
- A php sip client registers to remote asterisk server
- Php sip client sends to asterik the number to dial
- 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