2017-06-04 33 views
1

我正在使用C#代碼連接到Poloniex網站, 加密貨幣交換。我有兩個密鑰,第一個是API密鑰,最後一個是由Poloniex創建的,並通過電子郵件發送給我。我用第一個 鍵爲PublicKey,最後一個爲PrivateKeyPublicKeyPrivateKey上的ApiKeys.cs類。當我執行的程序,我 得到了錯誤如何使用Poloniex API與C#獲取實時價格數據

Additional information: The remote server returned an error: (403) Forbidden".

的鏈接,在[PoloniexApi.Net]項目(https://github.com/kripod/PoloniexApi.Net

struct ApiKeys 
{ 
    // WARNING: In order not to expose the changes of this file to git, please 
    //   run the following command every time you clone the repository: 
    // git update-index --assume-unchanged "PoloniexApi.Net.Demo\ApiKeys.cs" 
     internal const string PublicKey = "SUL0JADV-ZL02L4XQ-RZ9S0LIK-PIEJUAMD"; 
    internal const string PrivateKey = "4ac7bf2566503abc38e728ff72fc114ca2831bddd0ed0d432ba71da3a4dea36082a169cab5ffffcc1383ad23b60145bbb2d15da9f6396"; 
} 
  • 公鑰:API密鑰對Poloniex
  • PrivateKey:發送到郵件的關鍵Poloniex

enter image description here

+0

我也將兩個鍵交換在一起,我得到了同樣的錯誤。 –

+0

還顯示一些相關的代碼,例如如何將請求發送到Web服務,例如如何設置url。 – kennyzx

回答

1

有必要採取異常塊。例如:

try 
{ 
    var curr = CurrencyPair.Parse(Scurr); 
    var trade = await PoloniexClient.Trading.GetTradesAsync(curr); 
    dataGridTradeHistory.Rows.Clear(); 
    foreach (var trd in trade) 
    { 
    dataGridTradeHistory.Rows.Add(trd.Time, trd.Type, trd.IdOrder.ToString(), 
    trd.PricePerCoin, trd.AmountBase, trd.AmountQuote); 
    } 
} 
catch { }