473,385 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

[Q] How to Forumulate HTTP request using fsockopen() / fputs()

I am trying to get the file referenced by the following url:

http://waterdata.usgs.gov/wa/nwis/uv...te_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
Jul 17 '05 #1
3 4707
"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

--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #2
$lines =
file("http://waterdata.usgs.gov/wa/nwis/uv?dd_cd=01&dd_cd=02&format=rdb&peri
od=1&site_no=12149000");

duh!

Uzytkownik "Michael T. Peterson" <mt*****@comcast.net> napisal w wiadomosci
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

Jul 17 '05 #3
"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
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Gary Petersen | last post by:
For the benefit of others, I want to show how to do an HTTP POST request using fsockopen(). I banged my head against a wall for two days trying to figure this out. I even went to http://php.net/...
0
by: Spud | last post by:
<?php // pullpage function by Nick bouton http://www.nickbouton.com/. $CustomerID = "IDHERE"; $method = "POST"; $host = "xml.mydata.com"; $usepath = "/xml.asp"; //print all vars in an...
2
by: yawnmoth | last post by:
i'm trying to send an http post request and see if the server got it correctly. i'm sending the http post request with this script: <? $address = 'domain.tld'; $port = 80; $proxy =...
1
by: steven | last post by:
Hallo, I want to post an xml-doc to an URL using PHP. How can I do that ? //$dom is the xml dom which I want to send. $dom=domxml_open_file("example.xml"); Thanks,
10
by: Zack | last post by:
I am trying to figure out how to respond to an HTTP post in php script. Can anyone help?
4
by: Paul Dodowa | last post by:
Is it possible (i.e. are there any modules out there) that allows one to do HTTP tunneling from PHP? (Google is only bringing up ASP.NET links) I'm working with PHP5 so ideally, the code is PHP5...
6
by: Boldgeek | last post by:
I am trying to develop an app that will allow automatic updating of a web form which uses multipart/form-data enctype (as it MIGHT be sending an image) I have an example form, which when...
1
by: beau.moore | last post by:
Hi all, I need some help, I am trying to access a service that binds to the loopback address on my linux FC8 server. I think PHP functions but I am unable to get any response back from the...
5
by: matt | last post by:
This is a strange one but I've been stuck on it for days. Any help appreciated. THE PLAN: I've a database that I use a script to grab all the entries for a particular field. I then want to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.