473,322 Members | 1,259 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,322 software developers and data experts.

http-get and headers

Hi everyone...

I am looking to write code that can read a file from an http address
(for example: http://www.somesite.com/document.xml) and check it for any
changes (an updated state) then download it if it is a newer version. I
have seen references to the http-get functionality of PHP , but can't
find any examples or tutorials. Apparently I can check some http
headers to determine whether the document is new or not?

Can anyone direct me to some help on this issue?

Rick B
Jul 17 '05 #1
5 5087
rick wrote:
I am looking to write code that can read a file from an http address
(for example: http://www.somesite.com/document.xml) and check it for
any changes (an updated state) then download it if it is a newer
version. I have seen references to the http-get functionality of PHP
, but can't find any examples or tutorials. Apparently I can check
some http headers to determine whether the document is new or not?

Can anyone direct me to some help on this issue?


I am sorry I don't know too much about headers; but if I understand your
question correctly, you might alternatively want to look at the filemtime()
function in the PHP manual, which provides the last modification date of a
file as a UNIX timestamp.

--
Markus
Jul 17 '05 #2
Hello,

On 11/08/2004 05:38 AM, rick wrote:
I am looking to write code that can read a file from an http address
(for example: http://www.somesite.com/document.xml) and check it for any
changes (an updated state) then download it if it is a newer version. I
have seen references to the http-get functionality of PHP , but can't
find any examples or tutorials. Apparently I can check some http
headers to determine whether the document is new or not?

Can anyone direct me to some help on this issue?


You may want to do that using this HTTP client class and check for
Last-Modified or ETag headers:

http://www.phpclasses.org/mimemessage
--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #3
Manuel Lemos wrote:
Hello,

On 11/08/2004 05:38 AM, rick wrote:
I am looking to write code that can read a file from an http address
(for example: http://www.somesite.com/document.xml) and check it for
any changes (an updated state) then download it if it is a newer
version. I have seen references to the http-get functionality of PHP
, but can't find any examples or tutorials. Apparently I can check
some http headers to determine whether the document is new or not?

Can anyone direct me to some help on this issue?

You may want to do that using this HTTP client class and check for
Last-Modified or ETag headers:

http://www.phpclasses.org/mimemessage

Thanks...I'll check out that class. I do recall also seeing mentions of
ETag headers. So there isn't a native PHP function to handle this?
Jul 17 '05 #4
Hello,

On 11/08/2004 10:45 PM, rick wrote:
I am looking to write code that can read a file from an http address
(for example: http://www.somesite.com/document.xml) and check it for
any changes (an updated state) then download it if it is a newer
version. I have seen references to the http-get functionality of PHP
, but can't find any examples or tutorials. Apparently I can check
some http headers to determine whether the document is new or not?

Can anyone direct me to some help on this issue?
You may want to do that using this HTTP client class and check for
Last-Modified or ETag headers:

http://www.phpclasses.org/mimemessage

Thanks...I'll check out that class. I do recall also seeing mentions of


Sorry, I meant http://www.phpclasses.org/httpclient

ETag headers. So there isn't a native PHP function to handle this?


Header("ETag: ".$some_unique_value);

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #5
rick <rb*****@spamfree.net> wrote in message news:<ioFjd.60743$HA.8985@attbi_s01>...
Hi everyone...

I am looking to write code that can read a file from an http address
(for example: http://www.somesite.com/document.xml) and check it for any
changes (an updated state) then download it if it is a newer version. I
have seen references to the http-get functionality of PHP , but can't
find any examples or tutorials. Apparently I can check some http
headers to determine whether the document is new or not?


Perhaps <http://in.php.net/get_headers>. Look at Last-Modified and
ETag headers. The code for PHP 4 is at usernotes and it seems to be
faster than the function itself, but it doesn't handle redirects.

If the server doesn't send Last-Modified and ETag headers, the only
option is to md5_file() <http://in2.php.net/md5_file> the whole body
and check for freshness with the saved hash.

filemtime() will definitely not work for remote files.

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #6

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

Similar topics

8
by: ben | last post by:
I'm trying to write a web client script in python to log onto a web page and pull some information off of it. The page has quite a few behind the scenes http things going on that are making it...
8
by: turnit \(removethis\) | last post by:
I have a login form that uses the post method to carry the information to the next page. The form works just fine in ie6.0, but fails in mozilla and fails in ie5.2 on a mac. "HTTP/1.1 400 Bad...
17
by: Patrick | last post by:
I am almost certain that I could use HTTP Post/Get to submit XML Web Service call (over SSL as well, if using Version 3 of MSXML2) from an ASP Application? However, would I only be able to call...
24
by: sinister | last post by:
After doing a websearch, it appears that it's OK to omit the "http:" to form a relative URL. Are there any pitfalls to this? For example, if there is a page http://www.domain1.com/page1.html...
3
by: ashesdesign | last post by:
Hi All, I am very new to php and even newer to XML. Can anyone please shed some light on how to post XML requests via HTTP. I have been searching high and low and have come across many...
2
by: sushi | last post by:
Hello, I want to send a HTTP post request. The url will be given in the format http://host:port/remainder-of-URL where host is the DNS name or IP address of the host where the receiver is...
11
by: Tomas Kepic | last post by:
Hi, i'm trying to create my first ASP.NET project ( HelloASPWorld project) but an error occured when I put OK button in NewProject. ERROR: "The Web server reported the following error when...
4
by: Bob Badger | last post by:
Hi, Simple question (although I guess with a complicated answer). Is HTTP an async protocol? For instance, if I send a message to a c# webservice via http what is the protocol actually doing? ...
7
by: Andy Kendall | last post by:
Hi, This article states the following in relation to ASP.NET default test harness web pages. "These test pages can be used to invoke your WebMethods, but the test harness does this by making...
1
by: rpjd | last post by:
I am having a problem getting the http.status of an xmlhttprequest. The request readystate has come back as readystate 4, but then it stops without confirming the http.status. Any help appreciated....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.