deft Posted June 27, 2007 Share Posted June 27, 2007 I'm trying to use fsockopen(), fwrite(), etc. to post an XML document to a server in a special way. It's the server which delivers wap-push messages to our cell phones. I took the example code for using fsockopen() right from php.net and tried to adapt it but I can't get it to post properly. I do at least get connected to the server and get error messages from it. Mostly I've gotten 400; bad request. I think its' because the headers and XML document are not making it across as they should. Here's what I'm using; <?php $fp = fsockopen("atlsnup2.adc.nexteldata.net", 4445, $errno, $errstr, 999); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $out = "POST /ntfn/add HTTP/1.0\r\n"; $out .= "Accept: text\r\n"; $out .= "Content-type: application/vnd.uplanet.alert\r\n"; $out .= "Content-Length: 191\r\n"; $out .= "x-up-upnotifyp-version: upnotifyp/3.0\r\n"; $out .= "x-up-subno: 1132666310-43947622_atlsnup2.adc.nexteldata.net\r\n"; $out .= "x-up-ntfn-ttl: 0\r\n"; $out .= "x-up-ntfn-channel: push\r\n"; $out .= "Content-Location: http://wap.example.com/apage4u.wml\r\n"; $out .= "\r\n"; $out .= "<?xml version=\"1.0\"?>\r\n"; $out .= "<!DOCTYPE ALERT \nPUBLIC \"-//PHONE.COM//DTD ALERT 1.0//EN\" \"http://www.phone.com/dtd/alert1.xml\">"; $out .= "</xml>\r\n"; fwrite($fp, $out); while (!feof($fp)) { echo fgets($fp, 128); } fclose($fp); } ?> I got the instructions for what to post from the phone company's site. Any help getting this to work would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/57377-posting-an-xml-document-to-a-strange-server/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.