IOS: Current Weather API collation

Source: Internet
Author: User

Because of the weather forecast service, found that the online weather forecast interface and environmental data interface information is quite chaotic, and a lot of content has been invalidated, to collate some of the Information Bar.

Here is a copy of the answer you can refer to: (Point in time 2013-12-31)

http://www.zhihu.com/question/20521716

One, the interface is basically fixed to a point in time can not be used, most of the interface has been invalidated

Second, China's meteorological data open platform can not spit slot, log in always return to the page you just visited, and then jump to the login interface, jumping back and forth, is not able to log

For (a) The problem is a solution, method from the @ Cool Kid Article http://www.cnblogs.com/babycool/p/3575167.html grateful

The following is a method of obtaining the language written in OC

#defineCityweatherurl (Identifier) [NSString stringwithformat:@ "http://mobile.weather.com.cn/data/forecast/%@.html ", Identifier]Nsurlcache*urlcache =[Nsurlcache Sharedurlcache]; [Urlcache setmemorycapacity:1*1024x768*1024x768]; Nsurl*url =[Nsurl Urlwithstring:cityweatherurl (Cityidentifier)]; Nsmutableurlrequest*request =[[Nsmutableurlrequest alloc] init];  [Request Setcachepolicy:nsurlrequestreloadrevalidatingcachedata];  [Request Seturl:url]; [Request Sethttpmethod:@"GET"]; [Request SetValue:@"Application/json, Text/javascript, */*; q=0.01"Forhttpheaderfield:@"Accept"]; [Request SetValue:@"gzip"Forhttpheaderfield:@"accepts-encoding"];; [Request SetValue:@"zh-cn,zh;q=0.8"Forhttpheaderfield:@"Accept-language"]; [Request SetValue:@"http://mobile.weather.com.cn/"Forhttpheaderfield:@"Referer"]; [Request Settimeoutinterval: -]; //CacheNscachedurlresponse *responseu =[Urlcache cachedresponseforrequest:request]; if(Responseu! =Nil)  {[Request Setcachepolicy:nsurlrequestreloadignoringlocalandremotecachedata]; } [Nsurlconnection sendasynchronousrequest:request queue:[nsoperationqueue Mainqueue] CompletionHandler:^ (Nsurlresponse *response, NSData *data, Nserror *connectionerror) {    if([Data length] >0&& Connectionerror = =Nil) {Nsdictionary*jsonstring =[nsjsonserialization jsonobjectwithdata:data options:nsjsonreadingmutableleaves Error:nil]; //Do something          } Else if([data length] = =0&& Connectionerror ==nil) {//No Data          } Else if(Connectionerror! =Nil) {Nsdictionary*jsonstring =[nsjsonserialization jsonobjectwithdata:[responseu data] options:nsjsonreadingmutableleaves Error:nil]; //Do something}Else {    }  }];

For the Problem (ii) powerless

As for the third-party weather service try to find the part is not reliable also may I use the free version of it, there are aggregation data services can try, but I do not use, do not know whether it is feasible

IOS: Current Weather API collation

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.