. WIKIMERIONET
Merion Mertics , ,

-
-
CRM

5

2013 , Asterisk 12 - API, - ARI (Asterisk REST Interface). , php - .


Asterisk API?

, Asterisk : Asterisk Manager Interface (AMI) Asterisk Gateway Interface (AGI). AMI , , , call control. AGI, , , . , , AGI .

, , Asterisk. , AGI AMI .

ARI (Asterisk REST Interface). , ARI AGI AMI. (). , ARI , Asterisk .

  ARI (Asterisk REST Interface)

ARI REST , Asterisk, , , (), , , . JSON WebSocket.

: , , C Asterisk. ARI, , Python, Ruby, PHP JavaScript! , :

ari4java Java https://github.com/l3nz/ari4java
ari-py Python https://github.com/asterisk/ari-py
AsterNET.ARI C#/.NET https://asternetari.codeplex.com/
node-ari-client JavaScript (node) https://github.com/asterisk/node-ari-client
phpari PHP http://www.phpari.org/

: ARI Asterisk , . , .


phpari

ARI , WebSocket, http.conf, /etc/asterisk/:

cd /etc/asterisk/
vim http.conf

:

[general]
enabled = yes
bindaddr = 127.0.0.1

, ari.conf, vim ari.conf:

[general]
enabled = yes
pretty = yes

[__]
type = user
read_only = no
password = __

[__], , password . Asterisk:

asterisk rv
core restart now

phpari. composer:

composer, .

composer.json :

{
    "require": {
        "php": ">=5.3.9",
        "educoder/pest": "1.0.0",
        "devristo/phpws": "dev-master",
        "greenfieldtech-nirs/phpari": "dev-master"
    }
}

:

composer install

. /vendor/greenfieldtech-nirs/phpari phpari.ini:

cd /vendor/greenfieldtech-nirs/phpari
vim phpari.ini

:

[general]
debug=0
logfile=console ; #   ARI  ,      .     ,      ;

[asterisk_ari]
username= __
password= __
host=IP__Asterisk
port=8088
endpoint=/ari
transport=ws ; # , wss  ;

. .php , . , , phpari /vendor, ari.php :

require_once "vendor/autoload.php";
$ariCon = new phpari();
print_r($ariCon->channels()->channel_list());

. 1 Asterisk (, ). , :

php ari.php

, JSON , : context, exten, caller, accountcode .


?

. , Stasis:

exten => _XXXX,1,Stasis(_) 

ARI?

, ARI:

GET /channels/{channelId} channelId
POST /channels/{channelId} channelId
DELETE /channels/{channelId} (Hang Up)
POST /channels/{channelId}/continue ( )
POST /channels/{channelId}/continue ( )
POST /channels/{channelId}/answer
POST /channels/{channelId}/mute ""
DELETE /channels/{channelId}/mute " "
POST /channels/{channelId}/hold
DELETE /channels/{channelId}/hold
POST /channels/{channelId}/play
POST /channels/{channelId}/record
GET /bridges ()
GET /bridges ()
POST /bridges/{bridgeId}/addChannel
POST /bridges/{bridgeId}/removeChannel
GET /endpoints
GET /endpoints/{tech} ,
GET /endpoints/{tech}/{resource}
GET /sounds
GET /sounds/{soundId}

?


: