Re: [PHP-XML-DEV] http_post
[email protected] (Derick Rethans)
| Newsgroups | php.xml.dev |
|---|---|
| Message-ID | <[email protected]> |
Hello, please forward user questions to the [email protected] mailinglist, this list is for development _OF_ PHP, not development _with_ PHP. Derick On Fri, 28 Feb 2003, Diana Castillo wrote: > Hi , I am trying the following code to send XML but get no response from the > server, can someone tell me what I am doing wrong? thank you. > <?php > function http_post($server, $port, $url, $vars) { > // example: > // http_post( > // "www.fat.com", > // 80, > // "/weightloss.pl", > // array("name" => "obese bob", "age" => "20") > // ); > > $urlencoded = ""; > while (list($key,$value) = each($vars)) > $urlencoded.= urlencode($key) . "=" . urlencode($value) . "&"; > $urlencoded = substr($urlencoded,0,-1); > $content_length = strlen($urlencoded); > $headers = "POST $url HTTP/1.1 > Accept: text/plain, text/html, text/xml, image/gif, image/jpeg, > image/png, image/bmp > Accept-Charset: UTF-8 > Accept-Language: en > Content-Length: $content_length > Cache-Control: no-cache > Content-Type: application/x-www-form-urlencoded > Host: $server > User-Agent: Panasonic-GAD67/1.0 UP.Browser/5.0.3.5 (GUI) > Connection: Keep-Alive > > "; > $fp = fsockopen($server, $port, $errno, $errstr); > if (!$fp) { > return false; > } > fputs($fp, $headers); > fputs($fp, $urlencoded); > > $ret = ""; > while (!feof($fp)) > $ret.= fgets($fp, 1024); > fclose($fp); > return $ret; > } > > $request="<barceloDS_requests><request type='destination list' > id='8'><language_code>ESP</language_code><agency><primary>888</primary><seco > ndary>88</secondary><detail>888</detail><branch>1</branch></agency></request > ></barceloDS_requests>"; > > http_post("195.57.250.36",80,"/barceloDS/interface/xml/",array("xml" > =>$request)); > ?> > > > > -- Stop mad cowboy disease! ------------------------------------------------------------------------- Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ -------------------------------------------------------------------------