123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Net;
- using UnityEngine;
- using System;
- [Serializable]
- public class GetSky : MonoBehaviour
- {
- string weaidId;
- public Root roots;
- private void Start()
- {
- weaidId = "36";
- GetSkys();
-
-
- }
- public void GetSkys()
- {
- //version (版本号, v1代表7天, v6代表1天) 接口参数 cityid (城市编号), city (城市名称如:青岛), ip (ip地址, 默认当前ip天气)
- string parameters = "version=v6";
- string skyPath = "http://api.k780.com/?app=weather.today&weaId="+ weaidId + "&"+ "appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json";
- string url = String.Concat(skyPath, parameters);
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
- request.Method = "GET";
- request.Timeout = 5000;
- HttpWebResponse response = (HttpWebResponse)request.GetResponse();
- string jsonString;
- using (Stream stream = response.GetResponseStream())
- {
- StreamReader reader = new StreamReader(stream, System.Text.Encoding.UTF8);
- jsonString = reader.ReadToEnd();
- }
- //Root root = JsonUtility.FromJson<Root>(jsonString);
-
- //Response
- }
- }
- [Serializable]
- public class Results
- {
- public string weaid { get; set; }
- public string days { get; set; }
- public string week { get; set; }
- public string cityno { get; set; }
- public string citynm { get; set; }
- public string cityid { get; set; }
- public string temperature { get; set; }
- public string temperature_curr { get; set; }
- public string humidity { get; set; }
- public string aqi { get; set; }
- public string weather { get; set; }
- public string weather_curr { get; set; }
- public string weather_icon { get; set; }
- public string weather_icon1 { get; set; }
- public string wind { get; set; }
- public string winp { get; set; }
- public string temp_high { get; set; }
- public string temp_low { get; set; }
- public string temp_curr { get; set; }
- public string humi_high { get; set; }
- public string humi_low { get; set; }
- public string weatid { get; set; }
- public string weatid1 { get; set; }
- public string windid { get; set; }
- public string winpid { get; set; }
- public string weather_iconid { get; set; }
- }
- [Serializable]
- public class Root
- {
- public string success { get; set; }
- public string result { get; set; }
- }
|