Capture HTTP response Code through AGI
Posted: Thu Sep 13, 2018 12:55 pm
Hello,
I want to build an IVR which takes input from customer and passes to http. Upon successful validation of the input http response code is 200 else 302 and i want to capture these codes and proceed to next IVR extensions. Below is the IVR and php file
IVR------------------------------
exten => _X.,1,Answer()
same => n,AGI(sample.php)
same => n,Set(_response=${code})
same => n,NoOp(--Response Code is ${response})
PHP file-----------------------------------
[root@go agi-bin]# cat sample.php
#!/usr/bin/php
<?php
$domain1 = 'https://www.google.com=XXXXXXX';
function get_http_response_code($domain1) {
$headers = get_headers($domain1);
return substr($headers[0], 9, 3);
}
$get_http_response_code = get_http_response_code($domain1);
$agi->set_variable('get_http_response_code',$code);
$agi->verbose($code);
?>
Kindly help in how can i build the IVR using AGI and PHP
I want to build an IVR which takes input from customer and passes to http. Upon successful validation of the input http response code is 200 else 302 and i want to capture these codes and proceed to next IVR extensions. Below is the IVR and php file
IVR------------------------------
exten => _X.,1,Answer()
same => n,AGI(sample.php)
same => n,Set(_response=${code})
same => n,NoOp(--Response Code is ${response})
PHP file-----------------------------------
[root@go agi-bin]# cat sample.php
#!/usr/bin/php
<?php
$domain1 = 'https://www.google.com=XXXXXXX';
function get_http_response_code($domain1) {
$headers = get_headers($domain1);
return substr($headers[0], 9, 3);
}
$get_http_response_code = get_http_response_code($domain1);
$agi->set_variable('get_http_response_code',$code);
$agi->verbose($code);
?>
Kindly help in how can i build the IVR using AGI and PHP