4
我有以下代碼:捲曲 - 這個請求需要HTTP認證
$curl = curl_init($query);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLINFO_HEADER_OUT, 1);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl);
我沒有上傳爲AppFog應用程序,它工作正常。 問題是當我嘗試在Windows Server 2008 IIS7或WAMP上運行相同的代碼時。
我從服務器獲取以下信息:
HTTP Status 401 -
type Status report
message description **This request requires HTTP authentication().**
在看來,我不發送憑據,但「request_header」具有以下值:
POST /example HTTP/1.1
Authorization: Basic example // deliberately removed
Host: example.com
Accept: */*
Connection: close
Content-Length: 0
Content-Type: application/x-www-form-urlencoded
任何想法可能是問題?謝謝。
沒有用戶:通過你想實際使用的Windows服務器上工作? – 2013-04-26 21:57:58
我試圖連接到第三方服務器。所以憑證和URL在兩種情況下都是相同的。 – user1359575 2013-04-26 22:00:02
@MarcB是正確的。如果我沒有記錯的話,用戶名和密碼實際上需要與服務器進行身份驗證。如果您更換了服務器,則需要根據需要切換用戶/通行證。 – Kevin 2013-04-26 23:05:44