Possible duplicate:
Get the username, password parameters that passed through the curl
Hi, I use curl for authentication, and I send the username and password to the curl page as follows:
curl_setopt($curl, CURLOPT_USERPWD, 'john:12345');
And I have ANY authentication type set:
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
Now I want to know how I can get the username and password on my php page. When I use:, $_SERVER['PHP_AUTH_USER']I get no value.
Full code for reference:
<?php
$curl = curl_init('http://localhost/pt/public/api/v1/tags.xml');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERPWD, 'user:mypwd');
// $data = array('name' => 'Foo');
// curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'Sample Code');
$response = curl_exec($curl);
echo $response;
?>
Controller:
public function getAction()
{
print_r($_SERVER);
}
I saw the HTTP-based authentication with PHP in the PHP manual, but no one $_SERVER['PHP_AUTH_USER']and $_SERVER['PHP_AUTH_PW']does not appear.