Re: [php-139] cURL to pass htaccess authentication?

From: Charlie
Sent on: Monday, August 17, 2009 2:28 PM
Here is the htaccess portion to get you started:

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_USERAGENT, $ua);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, $return_contents);
        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); // Timeout for entire call.
        curl_setopt($ch, CURLOPT_FAILONERROR, 1); // Fail on HTTP code >= 400.
       
        if ($auth_user || $auth_pass)
        {
            curl_setopt($ch, CURLOPT_USERPWD, "{$auth_user}:{$auth_pass}");
            curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
        }
   
        // To set a timeout on the connection only:
        // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
       
        // To follow 302 redirects:
        // curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        // curl_setopt($ch, CURLOPT_MAXREDIRS, 100);
       
        $contents = curl_exec($ch);
       
        if ($error = curl_error($ch))
        {
           // Error here
        }
       
        curl_close($ch);


Charlie


From: Man Ma <[address removed]>
To: [address removed]
Sent: Monday, August 17, 2009 2:19:06 PM
Subject: [php-139] cURL to pass htaccess authentication?

Hi,
Anyone knows to how use CURL for htaccess authentication with SSL?

Thanks




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Man Ma ([address removed]) from The San Francisco PHP Meetup Group.
To learn more about Man Ma, visit his/her member profile
To unsubscribe or to update your mailing list settings, click here

Meetup Support: [address removed]
632 Broadway, New York, NY 10012 USA

IGN

Food, beverages, organizer time and give-aways.

Engineyard/Orchestra.io

Drinks at the 21st Amendment for the SFPHP Meeting-After-the-Meeting

O'Reilly User Group Program

The O'Reilly User Group Program provides the great books we get monthly.

People in this
Meetup are also in:

Log in

Not registered with us yet?

Sign up

Meetup members, Log in

or
By clicking the "Sign up using Facebook" or "Sign up" buttons above, you agree to Meetup's Terms of Service