Language

InformationSource Code
Accessing the Blizzard WoW Api requires me to expose the code used to access the Api from blizzard.
So here ya go:
Its written in C#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
usingSystem;
usingSystem.IO;
usingSystem.Net;
usingSystem.Security.Cryptography;
usingSystem.Text;

namespaceCSC.Net
{
publicclassWebRequest
{
staticstringpublicKey = "--------------";
staticstringprivateKey = "--------------";

publicstaticvoidCreateAuthentication(HttpWebRequestrequest)
{
using(HMACSHA1hmac = newHMACSHA1(Encoding.UTF8.GetBytes(privateKey)))
{
DateTimedate = DateTime.UtcNow;
stringstringToSign = request.Method + "\n"+ date.ToString("r") + "\n"+ request.RequestUri.AbsolutePath + "\n";
stringsignature = Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(stringToSign)));
request.Headers.Add("Authorization", "BNET"+ " "+ publicKey + ":"+ signature);
request.Date = date;
}
}

publicstaticstringGetWebRequestData(stringurl)
{
try
{
HttpWebRequestwr = (HttpWebRequest)HttpWebRequest.Create(url);
CreateAuthentication(wr);
WebResponse response = wr.GetResponse();
using(StreamReadersr = newStreamReader(response.GetResponseStream())) returnsr.ReadToEnd();
}
catch(Exception ex) { returnex.Message; }
}
}
}