Initial Release * * 0.2 -> Config options * * 0.3 -> Day and Night * *******************************/ /*Weather.com configuration ********************************/ $citycode = 'MXCA0026'; //Zip Code (US) or City code according to weather.com $partnerid = '1140062701'; //Partner ID $license = '5b323d77586070aa'; //License number /*Color Configuration ********************************/ $nightbackground = '#222'; //main colors. $daybackground = '#fff'; $daymaincolor = '#666'; $nightmaincolor = '#e1e1e1;'; $taglinecolor = '#999'; $coldcolor = '#78d6fd'; //Colors for each temperature. $coolcolor = '#1b95fb'; $temperatecolor = '#999'; $warmcolor = '#ff9226'; $hotcolor = '#ff1818'; /*Text Configuration *******************************/ $maintext = 'Juárez está:'; $title = '¿Cómo está el clima en Juárez?'; $coldstring = 'frio.'; //string for each temperature. $coolstring = 'fresco.'; $temperatestring = 'templado.'; $warmstring = 'cálido.'; $hotstring = 'caliente.'; $coldtagline = '(abrigate bien.)'; //tagline for each temperature. $cooltagline = '(perfecto para un saco.)'; $temperatetagline = '(ni fu ni fa.)'; $warmtagline = '(como para estar afuera.)'; $hottagline = '(hidrátate bien.)'; /*Temperature Configuration ******************************/ $coldlimit = 15; //How many degrees? (celsius) $coollimit = 20; $temperatelimit = 25; $warmlimit = 30; /****************************** * DANGER! DANGER! * ******************************* * Don't edit below this part * * unless you know what you're * * doing. * ******************************* * It's not that hard really. * * but it's better if we leave * * it like it is. Unless you * * like customizing the shit * * out of stuff. * *******************************/ $ch = curl_init('http://xoap.weather.com/weather/local/'.$citycode.'?cc=*&link=xoap&prod=xoap&par='.$partnerid.'&key='.$license.''); //Initialize curl. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //More curl config curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4); $data = curl_exec($ch); //this is your xml stuff curl_close($ch); $xml = new SimpleXmlElement($data, LIBXML_NOCDATA); //now let's make an XmlElement $feelslike = $xml->cc->flik; //This is the "Feel's Like temp" $sunset = date('G.i',strtotime($xml->loc->suns)); $sunrise = date('G.i',strtotime($xml->loc->sunr)); $now = date('G.i',time()-28800); $feelslike = ($feelslike -32)*5/9; //Convert fahrenheit to celsius. //now let's get the sponsored links. Stupid EULA. $sponsors = ''.$xml->lnks->link[0]->t.' · '; $sponsors .= ''.$xml->lnks->link[1]->t.' · '; $sponsors .= ''.$xml->lnks->link[2]->t.' · '; $sponsors .= ''.$xml->lnks->link[3]->t.''; if(isset($_GET['temp'])){ $feelslike = $_GET['temp']; //This overrides the weather.com temperature for debugging. } if(isset($_GET['now'])){ $now = $_GET['now']; //This overrides the weather.com temperature for debugging. } echo ' '; ?>
'.$coolstring.'
'.$cooltagline.''; } else if($feelslike < $temperatelimit){ echo ''.$temperatestring.'
'.$temperatetagline.''; } else if($feelslike < $warmlimit){ echo ''.$warmstring.'
'.$warmtagline.''; } else{ echo ''.$hotstring.'
'.$hottagline.''; } ?>