PHP标头信息

时间:2012-01-11 07:47:31

标签: php curl header http-headers httpresponse

我是一名PHP开发人员。我遇到了一个问题,即用户在使用CURL发送的请求中设置了“授权变量”。

在我的php代码中,我无法在curl请求期间获取用户设置的这些变量。请提前帮助谢谢。

1 个答案:

答案 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