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
1,568 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:
jk2001 earned 125 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 125 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now