【问题标题】:PHP Header informationPHP 头信息
【发布时间】:2012-01-11 07:47:30
【问题描述】:

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

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

【问题讨论】:

  • 你是怎么做到的?请在代码方面发布您到目前为止所获得的内容。

标签: php curl header http-headers httpresponse


【解决方案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

【讨论】:

    猜你喜欢
    • 2013-02-14
    • 2016-11-29
    • 2011-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多