";
if ($_POST['submit'] == 'view')
{
header("Content-type: text/xml");
echo $XML;
}
else
{
// Post header
$VS_header = "POST /ivrapi.asp HTTP/1.0\r\n";
$VS_header .= "User-Agent: IVR API\r\n";
$VS_header .= "Host: api.voiceshot.com\r\n";
$VS_header .= "Content-Type: text/xml\r\n";
$VS_header .= "Content-length: ".strlen($XML)."\r\n";
$VS_header .= "Connection: close\r\n\r\n";
$stream = fsockopen("api.voiceshot.com", 80);
if($stream)
{
fputs($stream, $VS_header);
fputs($stream, $XML);
$response="";
$header = "";
// code for parsing out the returned header
do $header.=fread($stream,1);
while (!preg_match('/\r\n\r\n$/',$header));
// Everything left is the XML response from the API
while(!feof($stream)) $response .= fgets($stream, 1024);
fclose($stream);
header("Content-type: text/xml");
echo $response;
}
}
?>
####
sub _vs_connectivity_check {
my $self = shift;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(POST => 'http://api.voiceshot.com/ivrapi.asp');
$req->content_type("text/xml");
$req->content( '');
my $res = $ua->request($req);
print $res->as_string;
}
####
HTTP/1.1 200 OK
Cache-Control: private
Connection: close
Date: Tue, 12 Jul 2005 19:27:30 GMT
Server: Microsoft-IIS/5.0
Content-Length: 87
Content-Type: text/html
Client-Date: Tue, 12 Jul 2005 19:34:08 GMT
Client-Peer: 64.105.135.234:80
Client-Response-Num: 1
Set-Cookie: ASPSESSIONIDACCABCRB=LPAGGBNCGIBHEMOHFDCAAMLJ; path=/