修改Mini天气预报app

作者:matrix 被围观: 1,730 次 发布时间:2013-10-03 分类:兼容并蓄 零零星星 | 无评论 »

这是一个创建于 3851 天前的主题,其中的信息可能已经有所发展或是发生改变。

Mini天气预报app v1.2

地址:http://demo.hhtjim.com

修改Mini天气预报app,之前使用的是专业气象的数据,这次改的189 API:http://api.189.cn/huafeng/api/getforecast24?access_token=91d1d9d25c62fd393e113116b07b6f601379679414323&app_id=120032470000032374&city_id=城市ID

参考:http://open.189.cn/index.php?m=api&c=index&a=show&id=359

城市ID列表 :http://open.189.cn/sharedata/cms/uploadfile/2012/1102/113459s3unXsSCAn.zip

主要代码:

  function getWeathers($city) {  
$wcity = file_get_contents("Liebiao.txt");  
         $pattern = "/([0-9]+)=" . $city . '/';  
preg_match_all ($pattern,$wcity,$titleList, PREG_PATTERN_ORDER);//使用preg_match_all正则匹配数据并保存到$titleList数组中  
            if ($titleList[0] == null) {  
             return null;  
         }  
$CITYID = explode('=',$titleList[0][0]);  
$Date = file_get_contents('http://api.189.cn/huafeng/api/getforecast24?access_token=91d1d9d25c62fd393e113116b07b6f601379679414323&app_id=120032470000032374&city_id='.$CITYID[0]);  
$cityinfO = explode('"',$Date); 
//echo $cityinfO[5];//$cityinfO[5] 城市名 
return $cityinfO; 
} 

     if ($_POST != null && $_POST["city"] != null) { 
         $cityinfOO = getWeathers($_POST["city"]); 
         if ($cityinfOO == null) {?> 
         <div class="alert alert-block" style="margin: 20px"> 
             <button type="button" class="close" data-dismiss="alert"> 
                 &times; 
             </button> 
             <h4>警告!</h4> 
              发生错误了亲,您输入的城市「<?php echo $_POST["city"]?>」好像没有找到哦! <a href="http://www.hhtjim.com/message-wall#comment">通知admin</a>  
         </div>  
         <?php return null;  
         }  
        // $cityinfO = $weather;  

         ?>  
         <table class="table table-striped table-bordered" style="margin-left: 20px;width: 500px"> 
             <thead> 
                 <th>实时天气信息</th> 
             </thead> 

             <tbody> 
         <?php 
echo "<tr><td>省份:</td><td>".$cityinfOO[7]."</td></tr>"; 
         echo "<tr><td>城市:</td><td>".$cityinfOO[5]."</td></tr>"; 
         echo "<tr><td>城市ID:</td><td>".$cityinfOO[9]."</td></tr>"; 
         echo "<tr><td>气象:</td><td>".$cityinfOO[13]."</td></tr>"; 
         echo "<tr><td>气温:</td><td>".$cityinfOO[19]."℃~".$cityinfOO[17]."℃</td></tr>"; 
         echo "<tr><td>风向:</td><td>".$cityinfOO[15]."</td></tr>"; 
echo "<tr><td>更新时间:</td><td>".$cityinfOO[11]."</td></tr>";  
         ?>                                  
             </tbody>                                

         </table>  
         <?php  
     }  
     ?>  

Mini天气预报app之前使用的是admin5的源码

Mini天气预报app v1.1

下载:http://pan.baidu.com/s/1cJSpO

http://www.400gb.com/file/30696317

参考:PHP利用天气API获取天气信息

其他文章:
本文固定链接:https://www.hhtjim.com/modify-the-mini-weather-app.html
matrix
本文章由 matrix 于2013年10月03日发布在兼容并蓄, 零零星星分类下,目前没有通告,你可以至底部留下评论。
转载请注明:修改Mini天气预报app-HHTjim'S 部落格
关键字:, ,

添加新评论 »

 🙈 😱 😂 😛 😭 😳 😀 😆 👿 😉 😯 😮 😕 😎 😐 😥 😡 😈 💡

插入图片

NOTICE: You should type some Chinese word (like “你好”) in your comment to pass the spam-check, thanks for your patience!