lists.zerezo.com
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
***BOGO*** Re: [PHP] Sending username/password
- Date: Fri, 05 Sep 2008 16:29:13 -0400
- From: Robert Cummings <robert@xxxxxxxxxxxxx>
- Subject: ***BOGO*** Re: [PHP] Sending username/password
On Fri, 2008-09-05 at 21:24 +0100, Stut wrote:
> Jay Moore wrote:
> > Stut wrote:
> >> On 5 Sep 2008, at 21:05, Robert Cummings wrote:
> >>> On Fri, 2008-09-05 at 15:01 -0500, Jay Moore wrote:
> >>>> Greetings list!
> >>>>
> >>>> Is it possible (and if so, how) to send username and password
> >>>> information to a website with PHP?
> >>>>
> >>>> I would like to submit some information to some network devices we
> >>>> have,
> >>>> but they require login credentials to proceed. I would like to bypass
> >>>> the traditional username/password prompt so I can automate the
> >>>> procedure.
> >>>>
> >>>> I hope this makes sense.
> >>>
> >>> If you mean http auth style login information then you do the following:
> >>>
> >>> http://www.somedomain.com:user@password/the/path/to/resource.html
> >>
> >> I think he meant
> >> http://user:password@xxxxxxxxxxxxxxxxxx/the/path/to/resource.html.
> >>
> >> Jay: How does the device ask for the username and password? Is it a
> >> form on the web page, a window from the browser, or what?
> >>
> >> -Stut
> >>
> >
> > Stut -
> >
> > Standard browser prompt. I'm usually pretty good with PHP stuff and
> > I've bypassed normal forms many times before, but I've never tried to
> > bypass the browser popup (.htaccess or similar, I presume?).
>
> The browser popup is caused by a requirement for HTTP authentication.
> Curl is your best bet for this. All you need to do is set the following
> option with the username and password...
>
> curl_setopt($curl_handle, CURLOPT_USERPWD, $username.':'.$password);
>
> ...for each request. If you don't have curl available then you can fall
> back on opening a socket and writing the HTTP request manually. If you
> need to do this lemme know - I have some code kicking around somewhere
> that does it.
Can also use file() or file_get_contents() if your PHP config enables
allow_url_fopen
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php