Re: authentication

From: Date: Wed, 28 Apr 2004 10:09:17 +0000
Subject: Re: authentication
References: 1  Groups: php.general.es 
Request: Send a blank email to general-es+get-48047@lists.php.net to get a copy of this message
Answer: I did it like this , adding the authentification string to the header function getResponse($request, $type){ $curl_interface = curl_init(); curl_setopt($curl_interface, CURLOPT_URL,AZOR_URL); curl_setopt($curl_interface, CURLOPT_POST, 1); curl_setopt($curl_interface, CURLOPT_POSTFIELDS,$request); curl_setopt ($curl_interface, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_interface, CURLOPT_HTTPHEADER,array("Authorization: Basic " . base64_encode(AZOR_USR . ":" . AZOR_PASSWORD))); $xml_response=curl_exec ($curl_interface); curl_close ($curl_interface); return $xml_response; } "Diana Castillo" <diana@hotelkey.com> wrote in message news:20040428092340.42851.qmail@pb1.pair.com... > I am making an xml connection , but first I need to authenticate myself, > they sent me the java code, which follows, any idea how to do the same thing > with php? > String userPwd = "<user>" + ":" + "<password>"; > String userPassword = Base64Converter.encode(userPwd.getBytes()); > uc = (HttpURLConnection) url.openConnection(); > Permission per = uc.getPermission(); > uc.setRequestProperty("Authorization", "Basic " + userPassword); > uc.setRequestMethod("POST");

« previous php.general.es (#48047) next »