C# 获取网络连接json

180it 2021-04-30 AM 1472℃ 0条
C#:
using System;
using System.Net;
using System.Web;

class CSharpExample
{
    public static void Main(string[] args)
    {
        try
        {
            Console.WriteLine(makeAPICall());
        }
        catch (WebException e)
        {
            Console.WriteLine(e.Message);
        }
    }

    static string makeAPICall()
    {
        var URL = new UriBuilder("https://fxhapi.feixiaohao.com/public/v1/ticker");

        var queryString = System.Web.HttpUtility.ParseQueryString(string.Empty);
        queryString["start"] = "5";
        queryString["limit"] = "5";
        queryString["convert"] = "USD";

        URL.Query = queryString.ToString();

        var client = new System.Net.WebClient();
        client.Headers.Add("Accepts", "application/json");
        return client.DownloadString(URL.ToString());
    }

}
支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

C# 获取网络连接json