@gpfspam

Проиграть звуковой файл с помощью phpari в Asterisk 16?

Хочу управлять Астером при помощи ARI. Почему php?, он мне ближе.

root@asterisk:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.8 (stretch)
Release: 9.8
Codename: stretch


asterisk*CLI> core show version
Asterisk 16.2.0-rc2


Настроил http.conf и ari.conf в астере

cat ari.conf
[general]
enabled=yes
pretty=yes
allowed_origins=*

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


cat http.conf
[general]
enabled=yes
enablestatic=yes
bindaddr=192.168.2.208
bindport=8088
prefix=asterisk


Проверил из CLI

asterisk*CLI> ari show status
ARI Status:
Enabled: Yes
Output format: pretty
Auth realm: Asterisk REST Interface
Allowed Origins: *
User count: 1


asterisk*CLI> http show status
HTTP Server Status:
Prefix: /asterisk
Server: Asterisk/16.2.0-rc2
Server Enabled and Bound to 192.168.2.208:8088

Enabled URI's:
/asterisk/httpstatus => Asterisk HTTP General Status
/asterisk/static/... => Asterisk HTTP Static Delivery
/asterisk/ari/... => Asterisk RESTful API
/asterisk/ws => Asterisk HTTP WebSocket

Enabled Redirects:
None.


Все, теперь я могу сделать вызов через ari.asterisk.org

Установил phpari через composer, настроил ini

cat phpari.ini
[general]
debug=9
logfile=console ; console for direct console output, filename for file based logging

[asterisk_ari]
username=test_ari
password=test_ari
host=192.168.2.208
port=8088
protocol=http
endpoint=/asterisk/ari
transport=ws ; ws for none encrypted, wss for encrypted (currently, only ws is supported)

[asterisk_manager]
username=test_ari
password=test_ari
host=192.168.2.208
port=8088


Теперь пытаюсь написать скрипт, взял чей то пример

cat test.php
#!/usr/bin/env php
<?php
require_once "./vendor/autoload.php";

    $conn     = new phpari("hello-world"); //create new object
    $channels = new channels($conn);

    $response = $channels->channel_originate(
        'PJSIP/1001',
        NULL,
        array(
            "extension"      => "s",
            "context"        => 'obzvon',
            "priority"       => 1,
            "app"            => "",
            "appArgs"        => "",
            "callerId"       => "1001",
            "timeout"        => -1,
            "channelId"      => '324234',
            "otherChannelId" => ""
        ),
        array("var1" => "cool")
    );
exit(0);
?>


Диалплан вот такой, и по нему вызов уходит, и играет музыка

cat extensions.conf
[obzvon]
exten => s,1,Wait(2)
exten => s,n,Playback(/var/lib/asterisk/sounds/music)
exten => s,n,Hangup


И теперь не могу понять, как мне дописать мой скрипт чтобы через него проигрывалась музыка.
Кто работал с PHPARI, подскажите куда копать
  • Вопрос задан
  • 796 просмотров
Пригласить эксперта
Ответы на вопрос 1
GoooodBoy
@GoooodBoy
Вам надо в диалплане завести выполнение в скрипт, примерно так
same => n,Stasis(hello-world)
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы