一、申请API(拿好appid和private_key)

echo urlencode(base64_encode(hash_hmac(‘sha1’, “ http://open.weather.com.cn/data/?areaid=101010100&type=index_f&date=201409041509&appid=15ds45s13a465s”,
“46s4ds_SmartWeatherAPI_45s44d6”, TRUE)));

首先定义得到public_key和API的方法,还有就是对key进行encodeurl操作的方法 注意,这里的方法都是被我定义在getTime的类里面,后面是在main中实例化出来的
//获得publicky
- (NSString) getPublicKey:(NSString)areaid :(NSString)type :(NSString)date :(NSString*)appid {
NSString *Key = [[NSString alloc] initWithFormat:@”http://open.weather.com.cn/data/?areaid=%@&type=%@&date=%@&appid=%@”,

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/138605.html