Re: send XML thru POST
| From: | Great Rhemax | Date: | Fri, 11 Jun 2004 13:22:30 +0000 |
| Subject: | Re: send XML thru POST | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-23963@lists.php.net to get a copy of this message | ||
Say you want to send the XML data to: http://myserver.com/listener.php
The you should use:
$fp = fsockopen (myserver.com, 80, $errno, $errstr, 30);
and later down
fputs($fp, "POST /listener.php HTTP/1.0\r\n");
"Joakim Ling" <joakim.ling@lokalguiden.se> wrote in message
news:04c001c44f84$c290e690$2300a8c0@lokalguirdcfee...
> Hi
>
> Im tring to send XML thru POST to a server. I have a demo in asp that
> works fine but how do I write this in php.
>
> This is the ASP demo
> sXML = "<?xml version=""1.0""
> encoding=""ISO-8859-1""
> Set oHttpConn = CreateObject("MSXML2.ServerXMLHTTP")
> Call oHttpConn.Open("POST", sURL, False)
> Call oHttpConn.setRequestHeader("Content-Type", "Text/xml")
> Call oHttpConn.send(sXML)
> sXMLResponse = oHttpConn.responseText
> Set oHttpConn = Nothing
>
>
> I tried this from the php-manual but no result. Its like it cant find
> the remote server.
>
> $fp = fsockopen ($sUrl, 80, $errno, $errstr, 30);
> $msg = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"";
> if (!$fp) {
> print("$errstr ($errno)<br>\r\n");
> } else {
> if ($fp) {
> fputs($fp, "POST /$sUrl HTTP/1.0\r\n");
> fputs($fp, "Content-Type: text/xml\r\n");
> fputs($fp, "Content-Length: ".strlen($msg)."\r\n");
> fputs($fp, "\r\n");
> fputs($fp, $msg);
> $content = 0;
> $reply = array();
> while (!feof($fp)) {
> echo fgets ($fp,128);
> }
> fclose($fp);
> }
> }
>
>
> Thanks for help.. // Jocke