Integration of asterisk with mysql using agi scripts

hello dear friends, wish you all be happy!
I want to use agi scripts using php to insert the audio file in mysql , I need urgent help can anyone help me please!

What exactly do you mean with insert the audio file in MYSQL ?

I want the user to record his/her voice and after recording it should be save to database.

usualy you save the recording path on a DB field, you can do this directly from the dialplan using system command, also you can do it using a basic php script and passing the argument in the array $argv, and also using odbc

can you send me the code, please!

This is the script:

#!usr/bin/php -q

<?php[quote="ambiorixg12, post:4, topic:75613, full:true"] usualy you save the recording path on a DB field, you can do this directly from the dialplan using system command, also you can do it using a basic php script and passing the argument in the array $argv, and also using od require 'phpagi.php'; error_reporting("E_ALL"); $agi = new AGI(); $agi->answer(); $hostname='localhost'; $dbname='consultation'; $username='tomy'; $password='1122'; $conn = new mysqli($hostname, $username,$password,$dbname); if($conn -> connect_error){ $agi->verbose('connection failed: '. $conn->connect_error); exit; } $contact_num = $agi-> request("agi_callerid"); $voice= $agi->request("/var/lib/asterisk/sounds/your_voice.wav"); $voice=$voice["result"]; $query="insert into `users` (voice) value ($voice) where `id`='3'"; $result = $conn -> query($query); if($result==true) $agi->verbose("*******inserted ok*******\n"); else $agi->verbose("*******insert failed: " . $conn->error); $conn->close(); $agi->hangup(); ?>

This is a community forum, nobody write custom code for other members, and even though i did it I will have to start to explain you how to implement it and it is I time I cant invest, I gave you a general idea of how to do it , now is your turn start reading and test ing

1 Like