Running a PHP script in dial plan

MailSouth

Joined
Sep 23, 2007
Messages
49
Likes
0
Points
0
#1
I have a dial plan that has the caller enter in their employee id. I want to then run a php script to verify that the caller used a valid employee id. The php script would return a true or false. If the answer is true I want to do one thing and if it is false I want to do something else.
What dial plan command can I use for that database validation in the dial plan?
 

cnasterisk

Joined
Nov 12, 2009
Messages
2
Likes
0
Points
0

haamed

Joined
Jul 23, 2007
Messages
251
Likes
0
Points
0
#3
for running php program and handling AGI whit that, you can follow this intro...
if you use ELastix, by default the PHP-AGI is installed...

1) make custom_extension to send calls to your PHP program..
edit etc/asterisk/custom_extension.conf and add the follow

Code:
include => php

[php]
exten => 8002,1,AGI(first-php.php)
exten => 8002,n,Hangup
now when you dial 8002 on Elastix it will goes to you first-php file...

2) Now you should make your php file..

this is a sample..
Code:
#!/usr/bin/php -q
<?php

  require('phpagi.php');
  error_reporting(E_ALL);

    $agi-> stream_file('welcome');
    //Get Data
    $data = $agi->get_data('beep', 3000, 1);  
    $data = $code['result'];
    //Say Given Number
    $agi-> say_number($height);

?>

Make this .php file and set 777 permission and put it in /var/lib/asterisk/agi-bin directory.
This sample will say 'welcome' and get digits and say given digits...

You can find more agi command in this file:
/var/lib/asterisk/agi-bin/php-agi.php or you can find more on voip-info.org


GoodLuckB)
 

danardf

Joined
Dec 3, 2007
Messages
8,069
Likes
10
Points
88
#4
Hi.

And it's possible to view all AGI commands with the CLI mode.
CLI> agi show [return] or
CLI> agi show cmd [Return]

example:
Code:
CLI>  agi show say number
 Usage: SAY NUMBER <number> <escape digits>
        Say a given number, returning early if any of the given DTMF digits
 are received on the channel.  Returns 0 if playback completes without a digit
 being pressed, or the ASCII numerical value of the digit if one was pressed or
 -1 on error/hangup.
CLI>

Regards
 

Members online

No members online now.

Latest posts

Forum statistics

Threads
30,902
Messages
130,886
Members
17,564
Latest member
Mai Tuyen
Top