Initial Release * * 0.2 -> Config options * * 0.3 -> Day and Night * * 0.4 -> Fancy Canvas Version * *******************************/ /*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 = '#21272A'; //main colors. $daybackground = '#99cce1'; $coldcolor = 'rgb(120,214,253)'; //Colors for each temperature. $coolcolor = 'rgb(27,149,251)'; $temperatecolor = 'rgb(153,153,153)'; $warmcolor = 'rgb(255,146,38)'; $hotcolor = 'rgb(255,24,24)'; /*Text Configuration *******************************/ $coldstring = 'frío.'; //string for each temperature. $coolstring = 'fresco.'; $regularstring = 'regular.'; $warmstring = 'cálido.'; $hotstring = 'caliente.'; $coldtagline = '(abrigate bien.)'; //tagline for each temperature. $cooltagline = '(perfecto para un saco.)'; $regulartagline = '(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); switch($xml->cc->icon){ case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 35: case 37: case 38: case 39: case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: $sky = 2; break; case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 33: case 34: $sky = 1; break; default: $sky = 0; } $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 date for debugging. } if(isset($_GET['sky'])){ //This overrides the weather.com sky conditions for debugging. $sky = $_GET['sky']; } echo ' '; ?>