@NYConsultant
Still interested in you version of the API. But at least I got the basics working:
For all the C# devs around here: This is the basic code to use the API as of today.
public static string GetBalance(string userName, string password)
{
// parameters: name1=value1&name2=value2
var parameters = "name=" + HttpUtility.UrlEncode(userName)
+ "&pass=" + HttpUtility.UrlEncode(password);
var req = (HttpWebRequest) WebRequest.Create("
https://mtgox.com/code/getFunds.php");
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
req.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)";
req.Accept = "application/json";
byte[] bytes = Encoding.ASCII.GetBytes(parameters);
req.ContentLength = bytes.Length;
Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
os.Close();
WebResponse resp = req.GetResponse();
try
{
var sr = new StreamReader(resp.GetResponseStream());
return sr.ReadToEnd().Trim();
}
catch (Exception ex)
{
Logger.Fatal(ex.Message);
Logger.FatalException(ex.InnerException.ToString(), ex);
return null;
}
} // end HttpPost
What got me stuck in the very beginning was that I lacked the UserAgent. This lead to TimeOuts without any (for me obvious) reason. After that I was having some issues with the combination of Url/HtmlEncode and the ContentType...
Any feedback appreciated.
Cheers
txcoin
PS:
As this may become out of date pretty much any moment, also look out for comments by "SlipperySlope" on how to do it in Java. The only change you have to make is that whenever we writes that he is using HtmlEncoding, in C# the UrlEncoding is needed.
PPS: Now I know why I need UrlEncode instead of HtmlEncode: it is the ContentType header
PPPS: Yes, this is some kind of x-post to the thread
http://forum.bitcoin.org/index.php?topic=25644