DEMO code of the weather query interface

Source: Internet
Author: User


DEMO code of the weather query interface:
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;
Using system. net. Security;
Using system. Security. cryptography. x509certificates;
Using system. net;
Using system. IO;
Using system. Io. compression;
Using system. Text. regularexpressions;
Using system. Web. Script. serialization;
Namespace Tianqi
{
Class Program
{
Static void main (string [] ARGs)
{
String key = "**********************"; // applied key value
String cityname = "Beijing"; // enter the name of the city to be queried.
String url = "http://apis.haoservice.com/weather? Cityname = "+ cityname +" & Key = "+ key;
WebClient WC = new WebClient ();
WC. Encoding = encoding. utf8;
String STR = WC. downloadstring (URL );
Console. writeline (STR );
Console. readkey ();

}
}
}

Sample Code returned by the weather query interface:
Weather query interface: http://www.haoservice.com/docs/6
Supported format: JSON
HTTP Request Method: Get post
Return example:
{
"Resultcode": "200 ",
"Reason": "query successful! ",
"Result ":{
"SK": {/* Current live weather */
"Temp": "21",/* Current temperature */
"Wind_direction": "West Wind",/* Current wind direction */
"Wind_strength": "Level 2",/* Current wind power */
"Humidity": "4%",/* current humidity */
"Time": "14: 25"/* Update time */
},
"Today ":{
"City": "Tianjin ",
"Date_y": "August March 21, 2014 ",
"Week": "Friday ",
"Temperature": "8 ℃ ~ 20℃ ",/* today's temperature */
"Weather": "smog",/* weather today */
"Weather_id": {/* unique weather identifier */
"Fa": "00",/* weather indicator 00: Sunny */
"FB": "53"/* weather id 53: haze if fa is not equal to FB, it indicates combined weather */
},
"Wind": "southwest wind Breeze ",
"Dressing_index": "cold",/* Dressing Index */
"Dressing_advice": "We recommend that you wear coats, coats, sweaters, and other clothing. ",/* Recommended clothes */
"Uv_index": "moderate",/* UV intensity */
"Comfort_index": "",/* comfort index */
"Pai_index": "More suitable",/* Car Wash Index */
"Travel_index": "suitable",/* Travel Index */
"Exercise_index": "More suitable",/* morning exercise Index */
"Drying_index": ""/* Drying Index */
},
"Future": {/* weather in the next few days */
"Day_20140321 ":{
"Temperature": "8 ℃ ~ 20℃ ",
"Weather": "clear and Haze ",
"Weather_id ":{
"Fa": "00 ",
"FB": "53"
},
"Wind": "southwest wind Breeze ",
"Week": "Friday ",
"Date": "20140321"
},
"Day_20140322 ":{
"Temperature": "9 ℃ ~ 21 ℃ ",
"Weather": "haze turns cloudy ",
"Weather_id ":{
"Fa": "53 ",
"FB": "01"
},
"Wind": "The Northeast breeze turns to the southeast Breeze ",
"Week": "Saturday ",
"Date": "20140322"
},
.......
"Day_20140327 ":{
"Temperature": "11 ℃ ~ 20℃ ",
"Weather": "Overcast to cloudy ",
"Weather_id ":{
"Fa": "02 ",
"FB": "01"
},
"Wind": "The southern breeze turns to the wind breeze without continuous wind Breeze ",
"Week": "Thursday ",
"Date": "20140327"
}
}
}
}

DEMO code of the weather query interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.