Jump to content

nifel87

Members
  • Posts

    4
  • Joined

  • Last visited

nifel87's Achievements

Newbie

Newbie (2/6)

1

Reputation

  1. Thanks again for the hint, I'll give it a try. When I'll have the code ready I'll post it on this page best regards nifel87
  2. Unfortunately, http://xml.weather.yahoo.com/ doesn't work anymore
  3. Hi! Thank you very much for the tip, I tried it and it works perfectly In these days I tried to change the function ___render() as follows: public function convertTemperature($temperature, $unit) { if (strtoupper($unit) == "C") { $temperature = round(($temperature - 32) / 1.8); } return $temperature; } public function convertWindSpeed($speed, $unit) { if ($unit == "km/h") { $speed = round($speed * 1.609344); } return $speed; } public function ___render() { if (wire('page')->template == 'admin') return; $scale = $this->scale == 1 ? 'f' : 'c'; $BASE_URL = "http://query.yahooapis.com/v1/public/yql"; $yql_query = 'select * from weather.forecast where woeid = '.$this->woeid; $yql_query_url = $BASE_URL . "?q=" . urlencode($yql_query) . "&format=json"; $weather = $this->getWeather(wire('config')->paths->siteModules . 'MarkupYahooWeather/cache/' . $this->woeid . '.json', $yql_query_url, $this->cache); if ($weather) { $json = json_decode($weather); $location = $json->query->results->channel->location; if (!empty($location)) { $current = $json->query->results->channel->item->condition; $wind = $json->query->results->channel->wind; $sun = $json->query->results->channel->astronomy; $unit = $this->scale == 1 ? 'mph' : 'km/h'; setlocale(LC_TIME, $this->locale); $out = "<div id='weather'>"; $out .= "<div class='location'>"; $out .= "<h1>" . $location->city . ", " . $location->country . "</h1>"; $out .= "<span>" . iconv($this->encoding, 'UTF-8', strftime($this->date, strtotime(date("d.m.Y.")))) . "</span>"; $out .= "</div>"; $out .= "<div class='current'>"; $out .= "<img src='" . $this->config->urls->MarkupYahooWeather . "icons/" . $current->code . ".png'/>"; $out .= "<span class='temp'>" . $this->convertTemperature($current->temp, $scale) . "°" . strtoupper($scale) . "</span>"; $out .= "<div class='condition'>" . __("Current:", __FILE__) . " <span>" . $this->getCondition($current->code) . "</span></div>"; if($this->wind == 1) { $out .= "<div class='wind'>" . __("Wind:", __FILE__) . " <span>" . $this->getWindDirection($wind->direction) . ", " . $this->convertWindSpeed($wind->speed, $unit) . " " . $unit . "</span></div>"; } if($this->time == 1) { $out .= "<div class='sun'>" . __("Sunrise:", __FILE__) . " <span>" . $this->getSunrise($sun->sunrise) . "</span> " . __("Sunset:", __FILE__) . " <span>" . $this->getSunset($sun->sunset) . "</span></div>"; } $out .= "</div>"; $forecast = $json->query->results->channel->item->forecast; if ($this->days == 1) { $out .= "<ul class='forecast'>"; for ($i = 0; $i < 5; $i++) { $out .= "<li>"; $out .= "<span class='day'>" . $this->getDay($forecast[$i]->day) . "</span>"; $out .= "<a class='weather-tooltip' data-toggle='tooltip' data-placement='top' title='" . $this->getCondition($forecast[$i]->code) . "'>"; $out .= "<img src='" . $this->config->urls->MarkupYahooWeather . "icons/" . $forecast[$i]->code . ".png'/>"; $out .= "</a>"; $out .= "<span class='high'>" . $this->convertTemperature($forecast[$i]->high, $scale) . "°" . strtoupper($scale) . "</span>"; $out .= "<span class='low'>" . $this->convertTemperature($forecast[$i]->low, $scale) . "°" . strtoupper($scale) . "</span>"; $out .= "</li>"; } $out .= "</ul>"; } $out .= "</div>"; return $out; } else { return __("This service is temporarily unavailable. Please try again later."); } } else { return __("Unable to contact the service. Please try again later."); } } If you want to, you can use it in a future version of this plugin with oauth support. In this code I use Json and the new address provided from YDN page. Sometimes, however, this new address (provided from yahoo) returns null as follow: { "query": { "count": 0, "created": "2016-04-02T18:00:17Z", "lang": "it-IT", "results": null } } ... and I don't understand why I hope this code will be helpfull for someone else, Best regards, nifel87
  4. Hi! Great module, very helpful. Sorry for my english, I'm not very good with it. I tried your module and at start It worked fine, but since 15th March 2016 Yahoo has introduced a new method for the authentication that use an oauth2 key. Because of this the module doesn't show any information anymore. I tried to fix it but I'm not good enough with php and service requests. Thx again for this module
×
×
  • Create New...