ASTERISK .... AGI script and URL

Hello All,

I’d appreciate greatly for a help on the below. I have tried to search the internet but with no success of how to implement this.

I am trying to implement the below:

  1. Pass parameter from an AGI script from the dialplan
  2. In the AGI script, pass the parameters to the URL and retrieve response from the URL
  3. Pass the retrieved response back to the dialplan for further use.

Thank you so much.


you can use CURL Operatation on dialplan or if you wan to do it in AGI, you can set a variable and get this variables from AGI and set variable again get from dialplan

I wrote this quick code using the phpagi class, I havent test it but it should work

#!/usr/bin/php -q
require_once('/root/phpagi-svn/phpagi.php');  //path to the class
$agi = new AGI();
$url=file_get_contents("https://development.myapi.php?id=$argv[1]"); // url and argument part
$agi->set_variable("result",$url);   //  the result of the url is saved on a variable called ${result}  so you can use it on asterisk side