Reputation: 1706
I'm currently writing a script that grabs a file from a website and then handles that data with some other scripts I've already written, however I'm having a little difficulty with logging in.
Where I'm having difficulty is in user authentication.
There is a login/password on the site itself, and that's fine. There are plenty of examples of how to submit form data using Curl to log in to a website.
But before logging in to the website it requires you to enter a username and password in an "Authentication Required" popup window;
A username and password are being requested by http://somemadeupwebsite.co.uk. The site says: "private"
Unfortunately I do not know how to get past this particular authentication via PHP. Beyond that point I shouldn't have any difficulty using curl to log in to the site itself via the username/password forms, and then grab my data, however I need to know if I can get over this first hurdle before I start putting the cart before the horse.
Is there a function capable of doing this, or a way of doing it via Curl?
If there's a way around this entirely that would be even better. If I could just log in to the site myself, and allow my script to share that authentication as well (the script will be running locally from the same browser), then this wouldn't be a problem.
Upvotes: 1
Views: 340
Reputation: 50563
That popup window is due to the site using Basic http authentication, cURL can go through it just by setting username and password like this:
curl_setopt($curl, CURLOPT_USERPWD, $user_here . ":" . $password_here );
Upvotes: 1