Entradas

Mostrando las entradas de septiembre, 2018

Mostrar el clima en tu página web con php

Imagen
Les dejo un script que estoy usando en algunos blogs de WordPress, sin plugin, asi limpito puro PHP, lo único que tienen que hacer es sacar una cuenta del API en http://api.openweathermap.org <?php // bs as 3435910 $apikey = "TUAPIKEY"; $url = "http://api.openweathermap.org/data/2.5/weather?id=3435910&appid=$apikey"; if ($url=@implode(file($url)) ) { $vars = json_decode($url); $temp = $vars->main->temp; $hume = $vars->main->humidity; $icon = $vars->weather[0]->icon; $temp_c = $temp - 273.15; ?> <div style="-webkit-box-shadow: 0px 0px 2px 0px rgba(0,0,0,0.75); -moz-box-shadow: 0px 0px 2px 0px rgba(0,0,0,0.75); box-shadow: 0px 0px 2px 0px rgba(0,0,0,0.75);;padding:10px;background:#ddd;width:100px;text-align:center;font-family:verdana,arial,times;font-size:12px;"> <img style="" src="http://openweathermap.org/img/w/<?php echo "$icon.png"; ?>"> <?php echo "&l