Poloniex İçin C# Api
-
Hocalar selam Poloniex üzerinden güncel listeyi almak alım satım yapmak gibi 3 temel işlemi botla yaptırmak istiyorum ancak resmi sitesi c# desteği vermiyor. İnternette httpwebrequest ile örnekler mevcut ancak bunlarda 403 döndermekte yada {"error":"Invalid command."} gibi hatalar vermekte. Alttaki koda el atabilecek var mı?
public static string _apiKey = "xxxx-CCSXBX5L-VZ9UVSD2-QAW95UPI"; // Random numbers and letters public static string _apiSecret = "xxxxxxxxxxxxxx"; public static long nonce = DateTime.Now.Ticks; public static string CreateSignature() { //string msg = string.Format("{0}{1}{2}", _apiKey); return ByteArrayToString(SignHMACSHA512(_apiSecret, StringToByteArray(_apiKey))).ToUpper(); } private static byte[] SignHMACSHA512(String key, byte[] data) { HMACSHA512 hashMaker = new HMACSHA512(Encoding.ASCII.GetBytes(key)); return hashMaker.ComputeHash(data); } private static byte[] StringToByteArray(string str) { return System.Text.Encoding.ASCII.GetBytes(str); } private static string ByteArrayToString(byte[] hash) //rimuove - e converte in bite { return BitConverter.ToString(hash).Replace("-", "").ToLower(); } static void Main(string[] args) { const string WEBSERVICE_URL = "https://poloniex.com/tradingApi"; try { var webRequest = System.Net.WebRequest.Create(WEBSERVICE_URL); if (webRequest != null) { webRequest.Method = "POST"; webRequest.Timeout = 12000; webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.Headers.Add("Key", _apiKey); webRequest.Headers.Add("Sign", CreateSignature()); // keysecret var postData = "nonce="+ nonce + "&command=returnBalances"; var data = Encoding.ASCII.GetBytes(postData); using (System.IO.Stream s = webRequest.GetResponse().GetResponseStream()) { using (System.IO.StreamReader sr = new System.IO.StreamReader(s)) { var jsonResponse = sr.ReadToEnd(); Console.WriteLine(String.Format("Response: {0}", jsonResponse)); } } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
-
const
string
WEBSERVICE_URL =
"https://<a class="
tbttag
" title="
poloniex
" href="
/tag/poloniex
">poloniex</a>.com/tradingApi"
;
bu satir bu sekilde mi yoksa copy paste yaparken mi boyle oldu?
oradaki <a href kismini ucur calisacaktir.
php api sorunsuz calisiyor birkac gun once denedim.
https://github.com/platedodev/Poloniex-API-for-PHP