Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

inblosam's scratchpad

by inblosam (Monk)
on Jun 05, 2004 at 12:07 UTC ( #361520=scratchpad: print w/ replies, xml ) Need Help??

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; } } } ?>
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2015-09-03 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred temperature scale is:










    Results (126 votes), past polls