Re: [Q] How to Forumulate HTTP request using fsockopen() / fputs()
From: Rahul Anand (rahulanand_bis_at_rediffmail.com)
Date: 01/24/04
- Next message: CountScubula: "Re: Dynamic images"
- Previous message: FLEB: "Re: Header Redirect Bug"
- In reply to: CountScubula: "Re: [Q] How to Forumulate HTTP request using fsockopen() / fputs()"
- Next in thread: Chung Leong: "Re: [Q] How to Forumulate HTTP request using fsockopen() / fputs()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 23 Jan 2004 22:11:42 -0800
"CountScubula" <me@scantek.hotmail.com> wrote in message news:<hciQb.16439$ED3.14970@newssvr25.news.prodigy.com>...
> "Michael T. Peterson" <mtp1032@comcast.net> wrote in message
> news:550d4e49c99e95f27df0df0d6e84488a@news.teranews.com...
> > I am trying to get the file referenced by the following url:
> >
> >
> http://waterdata.usgs.gov/wa/nwis/uv?dd_cd=01&dd_cd=02&format=rdb&period=1&s
> ite_no=12149000
> >
> > I'm using parse_url to get the host, path, and query. My call to
> > fsockopen() works correctly. Unfortunately, I can find no documentation
> for
> > how to construct a request that will correctly instruct the server (i.e.,
> > waterdata.usgs.gov) to send me the file and all the combinations of
> strings
> > hasn't worked.
> >
> > Can someone point me to some documenation that will explain how to
> construct
> > the query such that file can be obtained? A pointer to code snippets
> would
> > be useful as well, although I would really like to understand the precise
> > semantics.
> >
> > Thanks, in advance,
> >
> > Michael
> >
> >
>
> take a look at this:
>
> http://www-1.gzentools.com/snippetview.php?c=HTTP&v=getresource.php
To read a file from a web-server using HTTP following steps are
needed:
1. Open the socket to domain. [fsockopen]
2. Frame HTTP Request Command. (HEAD or GET) [check HTTP RFC form more
details]
3. Write the command to socket. [fputs/fwrite]
4. Read the socket for returned data. [fgets]
5. Close socket connection.
6. Parse the data to separate Header & Body part.
There are other methods also available in PHP:
if you have allow_url_fopen enabled at your server you can use many
other simple functions like:
file_get_contents
file
fopen+fread
etc.
But I think best solution will be using FTP function if you have
access have FTP access.
ftp_connect
ftp_login
ftp_get
ftp_fget
Please check PHP-Manual for more details about these functions.
-- Cheers, Rahul Anand
- Next message: CountScubula: "Re: Dynamic images"
- Previous message: FLEB: "Re: Header Redirect Bug"
- In reply to: CountScubula: "Re: [Q] How to Forumulate HTTP request using fsockopen() / fputs()"
- Next in thread: Chung Leong: "Re: [Q] How to Forumulate HTTP request using fsockopen() / fputs()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|