Advertisement
Guest User

blockChain

a guest
Sep 4th, 2017
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Newtonsoft.Json;
  8. using Newtonsoft.Json.Linq;
  9.  
  10. namespace CryptoMain
  11. {
  12.     public class BlockChain
  13.     {
  14.         private static string url = "https://blockchain.info/pt/ticker";
  15.         private static JObject j;
  16.  
  17.         private string GetResponse(string uri)
  18.         {
  19.             WebClient navegador = new WebClient();
  20.             return navegador.DownloadString(uri);
  21.         }
  22.  
  23.         /// <summary>
  24.         /// Use the following param: last, high, low
  25.         /// </summary>
  26.         /// <param name="node"></param>
  27.         /// <returns></returns>
  28.         public string GetDataByNode(string node)
  29.         {
  30.             j = JObject.Parse(GetResponse(url));
  31.             try
  32.             {
  33.                 return j["USD"][node].ToString();
  34.             }
  35.             catch (Exception )
  36.             {
  37.                 return "ERR";
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement