我们会看到很多网站都可以实时的显示当时当地的天气,下面我来告诉你这种实时天气的做吧,利用google aip接口即可实现获取不同城市的天气并显示在自己网站上。
se.php,代码如下:
- <?php
- $city = $_GET['city'];
- $data = createXml($city);
- $xml = simplexml_load_string($data);
- header("Content-type: text/xml");
- echo $xml->asXML();
- // 生成XML数据
- function createXml($city)
- {
- // Google 天气API
- $weather = simplexml_load_file("http://www.google.com/ig/api?weather={$city}");
- if(isset($weather->weather->forecast_conditions))
- {
- $low = f2c($weather->weather->forecast_conditions->low['data']);
- $high = f2c($weather->weather->forecast_conditions->high['data']);
- return "<weather>n<city>{$city}</city>n<low>{$low}</low>n<high>{$high}</high></weather>n";
- }
- else
- {
- return "<weather>n</weather>n";
- }
- }
- // 华氏度转摄氏度
- function f2c($fahrenhite)
- {
- return floor(($fahrenhite – 32) / 1.8);
- }
客户端 c.php,代码如下:
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>天气查询</title>
- </head>
- <body>
- <form method="post" action="">
- <select name="city">
- <option value="0">请选择</option>
- <option value="beijing">北京</option>
- <option value="shanghai">上海</option>
- <option value="guangzhou">广州</option>
- <option value="wuhan">武汉</option>
- </select>
- <input type="submit" />
- </form>
- <?php
- if(!emptyempty($_POST['city']))
- {
- $city = $_POST['city'];
- $xml = simplexml_load_file("http://127.0.0.1/rest/se.php?city={$city}");
- $html = "<p>City:{$xml->city}</p>n";
- $html .= "<p>Low:{$xml->low}</p>n";
- $html .= "<p>High:{$xml->high}</p>n";
- echo $html;
- }
- ?>
- </body>
- </html>
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
波比源码 » php获取google当前天气实现程序
波比源码 » php获取google当前天气实现程序
order generic levaquin 250mg levofloxacin sale
avodart 0.5mg canada celebrex 100mg pills zofran tablet
aldactone 100mg pill purchase propecia pill order fluconazole pill
order ampicillin 250mg without prescription ampicillin 500mg oral buy erythromycin 250mg
sildenafil canada fildena 100mg cheap robaxin for sale
tadalis price order tadacip 20mg sale order voltaren 100mg
buy accutane generic buy azithromycin 250mg pills zithromax over the counter
purchase indocin pill lamisil cost amoxicillin buy online
tadalafil 40mg brand do i have ed viagra 100mg
brand deltasone buy prednisone 10mg generic sildenafil 25 mg
cialis fГјr frauen tadalafil 5mg kaufen ohne rezept viagra 50mg kaufen generika
buy provigil 200mg pill Cialis in usa acetazolamide 250mg over the counter
purchase ramipril online azelastine 10 ml uk generic astelin 10 ml
buy catapres generic minocycline 50mg generic spiriva 9 mcg oral
buspar 10mg over the counter order ditropan 5mg generic buy oxybutynin 2.5mg
buy generic benicar order calan 240mg without prescription acetazolamide 250mg without prescription
purchase tacrolimus for sale purchase trandate sale ursodiol 300mg cheap
cost imdur 40mg order digoxin 250 mg for sale buy micardis online
zoloft price escitalopram 10mg cost order sildenafil for sale
imuran over the counter order viagra 100mg for sale real viagra 100mg
revia 50 mg cost order abilify generic buy aripiprazole 30mg generic
purchase modafinil sale canadian pharmacy online coupon ivermectin 6
piracetam 800mg ca piracetam 800mg canada sildenafil overnight shipping
brand lasix 40mg order doxycycline 200mg generic buy plaquenil 200mg online
cialis 20mg cost anafranil 50mg generic order clomipramine 50mg online cheap
zyprexa without prescription buy diovan 80mg generic cheap diovan 160mg
cheap clozapine decadron 0,5 mg ca buy dexamethasone 0,5 mg pill
viagra 50mg oral order sildenafil 100mg online lisinopril without prescription
zyvox online linezolid 600 mg pills online casino games for real money
order prilosec online omeprazole 10mg price free poker games
buy lopressor 50mg generic atenolol canada order levitra generic
order vardenafil 10mg sale purchase lyrica generic buy medrol 4 mg online
help writing paper best website for writing essays buy sildenafil 50mg without prescription
buy aristocort 10mg brand clarinex buy clarinex 5mg online cheap
buy dapoxetine 30mg generic buy cytotec without prescription synthroid pills
order tadalafil 40mg generic buy tadalafil 20mg pill sildenafil cheap
order xenical pill diltiazem 180mg usa order zovirax 800mg for sale
order zyloprim ezetimibe without prescription zetia canada
methotrexate 10mg generic oral metoclopramide buy reglan 10mg pill
domperidone price order cyclobenzaprine without prescription buy cyclobenzaprine online
losartan 50mg pills order cozaar 25mg pills order topamax 200mg online cheap
buy sumatriptan generic buy dutasteride generic brand avodart 0.5mg
ranitidine over the counter generic meloxicam order celecoxib pills
real money games casino free spin spins real money
zocor 10mg generic buy valtrex 1000mg without prescription buy generic finasteride 5mg
buy metronidazole 200mg without prescription metronidazole 200mg over the counter bactrim 480mg oral
help with assignments australia buy stromectol without prescription ivermectin 12mg for people
sildalis us lamotrigine 50mg without prescription lamotrigine order online
purchase azithromycin purchase prednisolone sale order neurontin 100mg without prescription
best online casino for real money order tadalafil 40mg for sale viagra cialis
prednisone 5mg brand order mebendazole 100mg generic order mebendazole 100mg online cheap
fildena online order sildenafil generic budesonide canada