Jump to content

Posting an XML document to a strange server


deft

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.