This is the PHP code I am trying to mimic in a HTTP post from PERL, I just can't seem to figure out what they key name is to post the XML to them. Any ideas?
<?php
if ($_POST['usedefault'] == '1')
{
$menuid = '0';
}
else
{
$menuid = $_POST['menuid'];
}
$errortext = '';
if ($_POST['phonenumber'] == '')
{
$errortext = "Required Field - PhoneNumber - is blank.";
}
else
{
if ($menuid == '') { $errortext = "Required Field - MenuID - is bla
+nk.";}
}
$XML = "<campaign action=\"0\" menuid=\"".$menuid."\">";
$XML .= "<phonenumbers>";
$XML .= "<phonenumber number=\"".$_POST['phonenumber']."\" callid=\"
+".$_POST['callid']."\">";
if ($_POST['tts'] != '') { $XML .= "<prompts><prompt promptid=\"2\"
+tts=\"".$_POST['tts']."\"/></prompts>"; }
$XML .= "</phonenumber>";
$XML .= "</phonenumbers>";
$XML .= "</campaign>";
if ($errortext != '')
{
echo "<html>".$errortext."</html>";
}
else
{
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;
}
}
}
?>
|