c# get api

admin 2021-05-15 15:29:43 478浏览 0评论
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.apishop.net/common/weather/get15DaysWeatherByArea");
            request.Method = "GET";
            request.ContentType = "application/json;charset=UTF-8";
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream stream = response.GetResponseStream();
            StreamReader reader = new StreamReader(stream, Encoding.GetEncoding("utf-8"));
            string json = reader.ReadToEnd();


            reader.Close();
            stream.Close();
            response.Close();


            //Console.WriteLine("Hello World!");
            Console.WriteLine(json);

            Console.ReadKey();


上一篇: c# get
0条评论