1

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.

Martyn Shutt
  • 1,671
  • 18
  • 25
  • possible duplicate of [How do I make a request using HTTP basic authentication with PHP curl?](http://stackoverflow.com/questions/2140419/how-do-i-make-a-request-using-http-basic-authentication-with-php-curl) – NullUserException Nov 29 '12 at 19:18
  • @NullUserException: Yes, the answer to my particular question is included in the question you linked to, however the OP also asks additional questions beyond the scope of what I needed to know. – Martyn Shutt Nov 29 '12 at 19:24

1 Answers1

1

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 );
Nelson
  • 49,283
  • 8
  • 68
  • 81
  • Ah. I didn't realise it was basic http authentication. I had come across the term, but wasn't sure it applied to what I was asking. All I needed to know. Thanks! – Martyn Shutt Nov 29 '12 at 19:20