gpt4 book ai didi

php - 使用 Zend_Http_Client 进行身份验证

转载 作者:搜寻专家 更新时间:2023-10-31 20:49:35 25 4
gpt4 key购买 nike

我正在尝试使用 Zend_Http_Client 在需要身份验证的站点上发出简单的发布请求。一切似乎都是正确的,但我仍然收到 You are not authorized to view this page 错误。任何想法可能是什么问题?我确定用户名和密码是正确的

    $client = new \Zend_Http_Client('http://ncmcrm/sales_summary/activity_range.asp');

$client->setHeaders('WWW-Authenticate', 'Negotiate');

$client->setParameterPost(array(
'from_day' => 1,
'from_month' => 1,
'from_year' => 2012,
'to_day' => 31,
'to_month' => 1,
'to_year' => 2012,
'user_id' => '{BCDF3313-9DBA-40E7-9CD8-02332F72A64F}'
));

$client->setAuth('******', '*****', \Zend_Http_Client::AUTH_BASIC);

$response = $client->request('POST');
print_r($response->getBody());

这是我在 Firebug 中为我感兴趣的 POST 请求获得的内容:

Response Headers
Connection close
Content-Length 4431
Content-Type text/html
Date Thu, 08 Mar 2012 19:13:11 GMT
Server Microsoft-IIS/5.0
WWW-Authenticate Negotiate NTLM
Request Headers
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Connection keep-alive
Content-Length 120
Content-Type application/x-www-form-urlencoded; charset=UTF-8
Cookie ASPSESSIONIDAAQSBCBQ=FEEOKMDAANCMKLGBKDBNKLHE
Host ncmcrm
Referer http://ncmcrm/sales_summary/sales_summary.asp
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2

最佳答案

您将 WWW-Authenticate header 设置为“Negotiate”,但随后您尝试使用 $this->setAuth 设置 Basic Auth header 。

假设 Web 服务器实际上允许基本身份验证,删除 $client->setHeaders('WWW-Authenticate', 'Negotiate'); 行应该可以。

关于php - 使用 Zend_Http_Client 进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9623768/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com