-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update and rename agi.conf to test.agi
- Loading branch information
1 parent
cacc750
commit 50622d5
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/php -q | ||
<?php | ||
// Reading AGI environment variables | ||
function readAgiVariables() { | ||
$agiVars = []; | ||
while ($line = fgets(STDIN)) { | ||
if (trim($line) == '') { | ||
break; | ||
} | ||
list($key, $value) = explode(': ', trim($line), 2); | ||
$agiVars[$key] = $value; | ||
} | ||
return $agiVars; | ||
} | ||
|
||
// Main logic of the AGI script | ||
$agiVars = readAgiVariables(); | ||
|
||
// Retrieve the variable MY_VARIABLE | ||
$myVariable = isset($agiVars['MY_VARIABLE']) ? $agiVars['MY_VARIABLE'] : 'Variable not set'; | ||
|
||
// Output the result | ||
echo "SET VARIABLE my_response \"$myVariable\"\n"; | ||
echo "SAY TEXT \"$myVariable\"\n"; | ||
echo "HANGUP\n"; | ||
?> |