Forum Moderators: coopster

Message Too Old, No Replies

Download a file using php

         

madmatt69

5:12 pm on Mar 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey all,
An affiliate company i work with has a feed they publish, and I'd like to download and save it as a txt file on my server.

How can I do this using php? I'm assuming I need write a small script that will get the file on their server, save it on my server (and change the extension to txt). Then I'm going to run this script via a cronjob.

Can anyone point me in the right direction to get started on this? I'm not sure which php command I need to use to grab the feed from the other server.

henry0

5:20 pm on Mar 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unless I do not understand you, if this is available to you they should have a link to it.
I doubt they will let you FTP to their server

as of now which kind of info do you have?

madmatt69

5:41 pm on Mar 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh yeah - I can link to it.

The url is like http://www.example.com/feed/data_feed.asp"

and i want to save it on my server as data_feed.txt. Changing the extension is no prob - I can do this manually (go to that URL, save the feed as txt and upload to my server). However the feed is updated every 15 minutes so I want to automate this using a cronjob. I'm assuming I need to write a small php script that pulls that feed and saves it to my server, and use the cronjob to execute the script.

Ya know? :)

[edited by: jatar_k at 5:44 pm (utc) on Mar. 19, 2007]
[edit reason] please use example.com [/edit]

Romeo

5:45 pm on Mar 19, 2007 (gmt 0)

10+ Year Member



If you have the power on your server to use cron, you may check if you can use `wget` or `curl` then, instead of writing an own PHP script.

Kind regards,
R.

madmatt69

5:50 pm on Mar 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That would definitely save some time. I'm looking into it now..

madmatt69

11:31 pm on Mar 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



wget was definitely the way to go. Thanks for the help!

henry0

11:00 am on Mar 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



in case anyone looks for

Read about it [gnu.org]