Re: fsockopen
| From: | Evan Nemerson | Date: | Tue, 25 Jun 2002 00:50:49 +0000 |
| Subject: | Re: fsockopen | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-103705@lists.php.net to get a copy of this message | ||
Try
fputs ($fp,"GET ".$url[path]." HTTP/1.0\r\nHost: " . $url[host] .
"\r\n\r\n");
Your old request looked like "GET / HTTP/1.0\r\nHost:value_of_host/\r\n\r\n",
hence the 400.
On Monday 24 June 2002 17:40 pm, Gerard Samuel wrote:
> Im trying to figure out fsockopen to grab an rdf file.
> Here is the code ->
> -----------------------------
> <?php
>
> $str = 'http://slashcode.com/slashcode.rss';
> $url = parse_url($str);
>
> $path = ($url['path']) ? $url['path'] : '/';
> $port = ($url['port']) ? $url['port'] : '80';
>
> if ($fp = fsockopen($url['host'], $port, &$errno, &$errstr, 5))
> {
> fputs ($fp,"GET / HTTP/1.0\r\nHost:" . $url[host] . $url[path] .
> "\r\n\r\n");
> while (!feof($fp))
> {
> echo fgets($fp, 1024);
> }
>
> fclose ($fp);
> }
> else
> {
> echo "Problem: $errno";
> }
>
> ?>
> -------------------------------------
>
> Its coming back with a HTTP/1.1 400 Bad Request
>
> Any help would be greatly appreciated.
> Thanks
--
Only one who devotes himself to a cause with his whole strength and soul can
be a true master. For this reason mastery demands all of a person.
Albert Einstein