Use China Weather Network interface Friends, everyone (and i) hard
If you are interested, you can get to know http://smart.weather.com.cn/wzfw/smart/weatherapi.shtml.
At the beginning of the year stopped using the previous interface, instead of applying for use, so sent a request for mail, the middle of various twists ... 10,000 words:
Finally the application came down, but the interface document AH, see I feel tired not love, the document only PHP version of the Kay generation method, I use on the Androi, those encryption methods do not know how to implement Java
Rage, just write a PHP version of it, originally was just want to write a generator key interface, and later thought to want to write a few lines directly to a step, eliminating the client on the multi-step network operation and string splicing
For half a day, just look at the effect.
Example:
Full code:
<?php/*----------This file need to be uploaded to their own external network space, no words can be the entire free cloud space I use the magic of the--------------*//*----------role: Access to this file only need to pass type and Areaid These two parameters, can be directly to the weather data/not to go back and forth the signature splicing and so on a lot of trouble things--------------*///China Weather Network SMARTWEATHERAPI Signature interface//signature generated direct access data// Parameter type: request data type; Areaid: City id//appid$app_id= ' your own AppID ';//privatekey$privatekey= ' your own Privatekey '; if (isset request[' type ']) &&isset ($_request[' Areaid ')) {//Receive parameter $type=$_request[' type ']; $areaid =$_request[' Areaid ' ];//formatting the current time yyyymmddhhmm$date=date (' Ymdhi ', Times ())//api request a fixed section $api_head= ' http://open.weather.com.cn/data/? Areaid= '. $areaid. ' &type= '. $type. ' &date= '. $date;//Stitching publickey$publickey= $api _head. ' &appid= '. $app _id;//Generate Key$sign_key=base64_encode (Hash_hmac (' SHA1 ', $publickey, $privatekey, True));// Intercept AppID Top 6 $api_url_appid=substr ($app _id,0,6);//splicing and UrlEncode processing final url$api_url= $api _head. ' &appid= '. $api _url_appid. ' &key= '. UrlEncode ($sign _key);//Save to the end, directly execute the generated URL Access data echo file_get_contents ($api _url);} Else{echo ' error ';}? >