"CountScubula" <me@scantek.hotmail.com> wrote in message news:<hc*******************@newssvr25.news.prodigy .com>...
"Michael T. Peterson" <mt*****@comcast.net> wrote in message
news:55******************************@news.teranew s.com... I am trying to get the file referenced by the following url:
http://waterdata.usgs.gov/wa/nwis/uv...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/snippetvi...etresource.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