我是一名PHP开发人员。我遇到了一个问题,即用户在使用CURL发送的请求中设置了“授权变量”。
在我的php代码中,我无法在curl请求期间获取用户设置的这些变量。请提前帮助谢谢。
答案 0 :(得分:1)
您要查找的值可能在$_SERVER
个变量中吗?
来自http://www.php.net/manual/en/reserved.variables.server.php:
'PHP_AUTH_DIGEST'
When doing Digest HTTP authentication this variable is set to the 'Authorization' header sent by the client (which you should then use to make the appropriate validation).
'PHP_AUTH_USER'
When doing HTTP authentication this variable is set to the username provided by the user.
'PHP_AUTH_PW'
When doing HTTP authentication this variable is set to the password provided by the user.
'AUTH_TYPE'
When doing HTTP authenticated this variable is set to the authentication type.
你应该能够像这样访问这些变量:
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
这将让您了解如何处理不同的摘要:http://php.net/manual/en/features.http-auth.php