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