Re: http_post
| From: | Derick Rethans | Date: | Fri, 28 Feb 2003 10:05:54 +0000 |
| Subject: | Re: http_post | ||
| References: | 1 | Groups: | php.xml.dev |
| Request: | Send a blank email to php-xml-dev+get-30@lists.php.net to get a copy of this message | ||
Hello,
please forward user questions to the php-general@lists.php.net
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>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/
-------------------------------------------------------------------------