G
G
gpfspam2019-04-15 14:47:27
Asterisk
gpfspam, 2019-04-15 14:47:27

Play sound file with phpari in Asterisk 16?

I want to manage Aster using ARI. Why php ?, it is closer to me.

[email protected]:~# 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

Configured http.conf and ari.conf in aster
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

Checked from 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.

Everything, now I can make a call via ari.asterisk.org
Installed phpari via composer, configured 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

Now I'm trying to write a script, I took someone's example
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);
?>

The dialplan is like this, and the call leaves on it, and music plays
cat extensions.conf
[obzvon]
exten => s,1,Wait(2)
exten => s,n,Playback(/var/lib/asterisk/sounds/music)
exten => s,n,Hangup

And now I can’t figure out how to add my script so that music can be played through it.
Who worked with PHPARI, tell me where to dig

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill, 2019-04-15
@GoooodBoy

You need to start execution in a script in the dialplan, something like this
same => n, Stasis (hello-world)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question