1
我正在嘗試使用暴雪的API從他們的JSON服務中檢索數據(身份驗證文檔 - http://blizzard.github.io/api-wow-docs/#features/authentication)。我目前有以下功能,照顧我的cURL請求:在PHP中驗證cURL請求
function get_json($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
我已經查看了身份驗證要求並獲得了公鑰和私鑰。它們提供了這一解釋過程:
UrlPath = <HTTP-Request-URI, from the port to the query string> StringToSign = HTTP-Verb + "\n" + Date + "\n" + UrlPath + "\n"; Signature = Base64(HMAC-SHA1(UTF-8-Encoding-Of(PrivateKey), StringToSign)); Header = "Authorization: BNET" + " " + PublicKey + ":" + Signature;
我曾嘗試研究PHP處理捲曲的認證,但它只是讓我感到困惑了。我的問題是如何在get_json函數中包含身份驗證?
發現的傢伙這段代碼,我發現這一點 - 和我試圖找出它的用武之地 curl_setopt($ CH,CURLOPT_HTTPHEADER, 「授權:基本」。BASE64_ENCODE( $ username。「:」。$ password))); – SystemX17