Reputation: 19837
I'm currently trying to grab a file from an external url that has an authorization box that pops up (like the default one asking for a username and password)
How can I have a script get the contents of the page (it's a video), save it to a directory and handle the authorization (i have a username and password)
Thanks :)
Upvotes: 0
Views: 98
Reputation: 70480
In a word, look at curl: http://php.net/curl, for all you posting/logging in/cookies/session needs in HTTP country.
Upvotes: 3
Reputation: 12721
You don't need to download the page, just check what is being submitted to the web server. Chances are it's just a POST. It may have some additional checks (i.e. checksum) which may need to be scraped from the page.
You can use the HTTP Headers plugin for Firefox to see how the browser is communicating with the server. You then just need to emulate that transaction. It is likely a POST, which is easy to do with CURL.
I don't think file_put_contents will work since it doesn't do an http POST.
Upvotes: 2
Reputation: 17977
file_put_contents('where to put it', file_get_contents('http://username:[email protected]/video'));
Upvotes: 3