Jump to content

Advanced CURL Help Need


burakc

Recommended Posts

Hi,

I am trying to connect a web page.

Its protected by 401 (htpasswd prot.) and Form login (http session prot.). My codes passing 401 pop up screen. But after that form login screen showing error: wrong password. How can i pass both of them. Sorry for my poor English. Thanks.

 

$curl = curl_init(); 
$timeout = 10;
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ; 
curl_setopt($curl, CURLOPT_USERPWD, "$htuser:$loginPassword");  
curl_setopt($curl, CURLOPT_HEADER, false); 
curl_setopt($curl, CURLOPT_POST, true); 
curl_setopt($curl, CURLOPT_POSTFIELDS, 'User='.$loginUser.'&password='.$loginPassword.'&submit='.$submit); 
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout);  
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); 
curl_setopt($curl, CURLOPT_URL, $url); 

$data = curl_exec($curl); 
print_r($data); 
curl_close($curl); 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.