Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to login to a remote site (username and password), spoof a cookie and download a file (locally to the server)!!

Posted on 2006-11-28
6
Medium Priority
?
1,575 Views
Last Modified: 2012-06-22
OK, apologies if this seems a lot of work, but it's really not such a big task.

I am hoping for some advice about mecanisms (bonus for some code to do it as well) to do the following things with a PHP script:
1)Call a URL
2)That URL requires a login, so I need to pass a username and password to the input boxes
3)Once logged into that site, I can call a second url (which is the equivalent of clicking a "download" button)
4)Receive the file back to the webserver (a simple CSV file) and store it in the desired location

I cannot confirm whether the site requires cookies or not.  If you know anything about cookie spoofing from a server, advice or resources would be appreciated.

This job will then be run on a Cron Job.

Many thanks for your time on this one experts.  EE has never ceased to amaze me, I'm sure it won't let me down this time!

Matt
0
Comment
Question by:LhXs
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
John Kawakami earned 500 total points
ID: 18033441
Study up on the cURL libraries.  They support posting forms and sending cookies.
0
 
LVL 11

Assisted Solution

by:ch2
ch2 earned 500 total points
ID: 18034088
You can use a HTTP class that will do the job for you.

This will do all 4 steps.

http://code.blitzaffe.com/pages/phpclasses/files/http_retriever_52-6
0
 

Author Comment

by:LhXs
ID: 18037149
Many thanks,
That does look like the sort of script I'm after but it doesnt provide much support or explanation on how to use it.  Anyone got any advice for it or useable scripts?

Thnaks for you help

Matt
0
 
LVL 11

Expert Comment

by:ch2
ID: 18037321
Inside the zip there is an example, but if you want more support use the method jk2001 cURL give you because it's a php library and is well documented.

Mike
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question