Use AsteriskmanagerAPI for automatic dialing

Source: Internet
Author: User
& Nbsp; in the example of implementing automatic call, I used the Originate method in AsteriskmanagerAPI, which is in phpagi. The specific definition is as follows: (I will not explain it in English, but I am very confused in English)/** & nbsp; * OriginateCall & nbsp; * & nbsp; & nbs

In the example of implementing automatic call, I used the Originate method in the Asterisk manager API, which is in phpagi. The specific definition is as follows: (I will not explain it in English. I am very confused in English)
/**
* Originate Call
*
* @ Link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Originate
* @ Param string $ channel Channel name to call
* @ Param string $ exten Extension to use (requires Context and Priority)
* @ Param string $ context Context to use (requires Exten and Priority)
* @ Param string $ priority Priority to use (requires Exten and Context)
* @ Param string $ application Application to use
* @ Param string $ data Data to use (requires Application)
* @ Param integer $ timeout How long to wait for call to be answered (in MS)
* @ Param string $ callerid Caller ID to be set on the outgoing channel
* @ Param string $ variable Channel variable to set (VAR1 = value1 | VAR2 = value2)
* @ Param string $ account Account account code
* @ Param boolean $ async true fast origination
* @ Param string $ actionid message matching variable
*/
Function Originate ($ channel,
$ Exten = NULL, $ context = NULL, $ priority = NULL,
$ Application = NULL, $ data = NULL,
$ Timeout = NULL, $ callerid = NULL, $ variable = NULL, $ account = NULL, $ async = NULL, $ actionid = NULL)
{
$ Parameters = array (Channel => $ channel );
 
If ($ exten) $ parameters [Exten] = $ exten;
If ($ context) $ parameters [Context] = $ context;
If ($ priority) $ parameters [Priority] = $ priority;
 
If ($ application) $ parameters [Application] = $ application;
If ($ data) $ parameters [Data] = $ data;
 
If ($ timeout) $ parameters [Timeout] = $ timeout;
If ($ callerid) $ parameters [CallerID] = $ callerid;
If ($ variable) $ parameters [Variable] = $ variable;
If ($ account) $ parameters [Account] = $ account;
If (! Is_null ($ async) $ parameters [Async] = ($ async )? True: false;
If ($ actionid) $ parameters [ActionID] = $ actionid;
 
Return $ this-> send_request (Originate, $ parameters );
}
The following is the simple code of the server (I just implement automatic dialing for this file, and the other party will hear the hello world Voice after receiving the answer)
Ami. php
#! /Usr/bin/php-q
Include "phpagi-asmanager.php ";
$ Ams = new AGI_AsteriskManager ();
$ Ams-> AGI_AsteriskManager ("ami. conf ");
$ Result = $ ams-> connect ();
$ Res = $ ams-> Originate (sip/8001,8001, from-internal, 1, Playback, hello-world, 30000,192.168 .1.112 );
Var_dump ($ res); // This is the debugging code for viewing output information.
?>
The ami. conf file is the authentication file for accessing the API: the content is as follows:
[Asmanager]
Server = 127.0.0.1; server to connect
Port = 5038; default manager port
Username = admin; username for login
Secret = 123456; password for login
The content of this file must be the same as the user password in the/etc/asterisk/manager. conf file in asterisk. the above two files are stored in the/var/spool/asterisk/outgoing/directory.
(Permission to be executed)
After writing the above code, you can directly run it on the server to call the dial-up:
Run./ami. php

You can expand the parameters by yourself. for example, you can access the website to pass the call parameters! Or you can use some programs to automatically execute this program! I just want to use this on server monitoring. I don't need to use the old text message to remind me. if the server goes down, I will call the person in charge directly. after the connection, I will automatically dial the recording and play it cyclically, it's hard for him to know!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.