Your question interested me for my own work, so I found this url:
   http://www.zend.com/zend/spotlight/mimocsumissions.php

The script, disentangled from the commentary (& with a few of my own comments) is as follows:



function post_it($datastream, $url)
{

  $url = preg_replace("@^http://@i";, "", $url);
  $host = substr($url, 0, strpos($url, "/"));
  $uri = strstr($url, "/");

  $reqbody = "";
  foreach($datastream as $key=>$val) {
      if (!empty($reqbody)) $reqbody.= "&";
  $reqbody.= $key."=".urlencode($val);
  }

// the trick here is to know that the Host // header identifies the script, not the uri
  $contentlength = strlen($reqbody);
  $reqheader =  "POST $uri HTTP/1.1\r\n".
               "Host: $host\n". "User-Agent: PostIt\r\n".
  "Content-Type: application/x-www-form-urlencoded\r\n".
  "Content-Length: $contentlength\r\n\r\n".
          "$reqbody\r\n";

    $socket = fsockopen($host, 80, $errno, $errstr);

   if (!$socket) {
      $result["errno"] = $errno;
      $result["errstr"] = $errstr;
      return $result;
   }

  fputs($socket, $reqheader);

  while (!feof($socket)) {
     $result[] = fgets($socket, 4096);
  }

  fclose($socket);

  return $result;

}

?>

<?php

$data["xml"] = $xml_data; //here of course "xml" will be replaced by // your own name for the value $xml_data


$result = post_it($data, "http://www.example.com/cgi-bin/test/script.php";);

  if (isset($result["errno"])) {
    $errno = $result["errno"];
    $errstr = $result["errstr"];
    echo "<B>Error $errno</B> $errstr";
    exit;
  } else {

    for($i=0;$i< count($result); $i++) echo $result[$i];

  }

?>

Rosen wrote:
"Unknown Sender" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
Hi Rosen,
You can do this for some ways.
The simplest:
1. Send via ftp - http://php.net/ftp
2. Send via scp using ssh2 - http://php.net/ssh2

Regards
Michael

Thanks Michael, but I want if it is possible to do something like "POST" in normal HTML language and "say" to the remote script to process XML. And I don't have FTP access to remote server. The idea is to working only with XML protocol to communicate with remote server. I think I have read something like this in the internet, but can't remember where :(

Regards
Rosen



Rosen said:
Hi,

I need to create an XML file and send it to another server, where script process the XML. With creation and processing of XML I don't have a promlems, but how I can send XML to the processing script on another server ?


Thanks in advance,
Rosen


--

_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to