phpasteriskasteriskami

Asterisk/PHP - How to get list of call recordings


I want to use AMI(Asterisk Manager Interface) to get the list of calls recorded and then get/fetch one of them to be played in my site. What I expect for listing recordings is like this: asterisk-site-example.com/recordings and for each one like this: asterisk-site-example.com/recordings/23. But I don't know which method should I use to get all recordings and each one separately.

What I have done:

composer require marcelog/pami

my code:

require __DIR__ . '/vendor/autoload.php';

$options = [
    'host' => '192.168.1.10',
    'scheme' => 'tcp://',
    'port' => 5038,
    'username' => 'admin',
    'secret' => 'admin',
    'connect_timeout' => 30,
    'read_timeout' => 30
];

try {
    $client = new \PAMI\Client\Impl\ClientImpl($options);
    $client->open();

    // What should I do here? Which method should be used?

    $client->close();
} catch (\Exception $e) {
    die('Ex: '.$e->getMessage());
}

Solution

  • AMI does not support Pull/Get of a Monitored call.

    See here

    One way for you to be able to list and pull Monitored calls is to either be locally on the box (which I understand you have no access to)

    Another way is to create a custom web API, again local to Asterisk, with which you can then communicate. It could be PHP / Python, anything.

    A third option that I see, is for the folder where the monitored calls are /var/spool/asterisk/monitor to be accessible to your remote box via NFS, so you can then have the monitor files and list/read/get them from your remote machine as local files.

    But AMI cannot directly (yet) do that.