Re: HTTP_POST Intermittent Problem
| From: | Matt M. | Date: | Thu, 26 Aug 2004 18:11:30 +0000 |
| Subject: | Re: HTTP_POST Intermittent Problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-194826@lists.php.net to get a copy of this message | ||
> function http_post($host, $path, $data)
> {
> $http_response = '';
> $content_length = strlen($data);
>
> $fp = fsockopen($host, 80);
> fputs($fp, "POST $path HTTP/1.1\r\n");
> fputs($fp, "Host: $host\r\n");
> fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
> fputs($fp, "Content-Length: $content_length\r\n");
> fputs($fp, "Connection: close\r\n\r\n");
> fputs($fp, $data);
> while (!feof($fp))
> {
> $http_response .= fgets($fp, 128);
> }
> fclose($fp);
>
> return $http_response;
> }
>
> $http_response = http_post('www.blah.com', '/test.aspx?',
> 'data');
can you use PEAR?
There is already a bunch of http packages
http://pear.php.net/package-search.php?pkg_name=http&bool=AND&submit=Search