asterisk with php
| From: | hadi | Date: | Wed, 22 Jul 2015 18:21:25 +0000 |
| Subject: | asterisk with php | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-325008@lists.php.net to get a copy of this message | ||
Hi,
I have project, Asterisk with phpagi, when I pass variable to function I get
error "Notice: Undefined variable: pin".
Here is my code
#!/usr/local/bin/php -q
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require("phpagi.php");
require("database.php");
$agi=new AGI();
$agi->answer();
for ($x = 0; $x <= 3; $x++)
{
$result = $agi->get_data('/var/lib/asterisk/agi-bin/ivr-sound1', 3000, 20);
$pass = $result['result'];
$query = $conn->prepare("SELECT COUNT(*) FROM userinfo where pin=:pin");
$query->bindParam(':pin', $pass);
$query->execute();
$num_rows = $query->fetchColumn();
if($num_rows == 1)
{
$agi->text2wav("thankyou");
$agi->text2wav("please enter number to dial for more information press
zero");
$num = $agi->exec("Read","pin,,4,3,120");
$temp = $agi->get_variable("pin");
$pin = trim($temp["data"]);
global $pin;
break;
}
if ($x == 3)
{
$agi->hangup();
}
}
dialout($pin);
function dialout($pin)
{
$agi=new AGI();
$agi->exec_dial("SIP/$pin");
$Answeredtime = $agi->get_variable ("ANSWEREDTIME");
$agi->hangup ();
}
?>