| 
	
 | 
 Posted by Ulf Kadner on 08/12/07 22:25 
Stefano wrote: 
 
> So, after curl_init(), using the function : 
>  
> curl_setopt($curl, CURLOPT_HTTPAUTH, 'username:password'); 
>  
> I get the same error message as before: 401 Unauthorized. 
 
Right. It was my failure. Better to read my posting before send. 
Yesterday i used it like my example but with PROXY* Paramater. worry? :-) 
 
> curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 
>  
> Seems that username:password is not accepted as CURLOPT_HTTPAUTH set value. 
> In that case where should I specify login and password ? 
 
The fast and bad way is URL-injection like this: 
http://username:password@example.com/... 
 
The other and better way is to change youre code at line: 
$headers.="Authorization: Basic root:password_root".$br.$br; 
 
to: 
$headers .= 'Authorization: Basic ' 
          .  base64_encode('root:password_root') . $br . $br); 
 
The RFC says username:password must be Base64 encoded. 
 
By the way: A good PHP-Library for doing something more with  
http/ftp/... (by a easy way) is Snoopy. 
http://sourceforge.net hosts it. 
 
--  
    _, 
  _(_p>   Ulf [Kado] Kadner 
  \<_) 
   ^^
 
[Back to original message] 
 |