2
我試圖使用Zend_Http_Client在需要身份驗證的站點上發出簡單的發佈請求。一切似乎是正確的,但我仍然得到一個You are not authorized to view this page
錯誤。任何想法可能是什麼問題?我敢肯定的用戶名和密碼是否正確使用Zend_Http_Client進行身份驗證
$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
這個$ client-> setAuth('******','*****',\ Zend_Http_Client :: AUTH_BASIC); – HaRsH 2015-05-18 14:47:31