ちょっと、私は場所のすべてを検索し、本当に私の心を構成することはできません。私は天気予報ウィジェットをインストールしてヤフーサーバーから天気を引き出すが、いくつかのことをする方法を理解することはできない。何らかのハックなしで自動的にDAYからNIGHTに切り替えることができました。私は5日間の予告を引き出す方法もわかりません。本当に良い堅牢なjqueryの天気の実装は、ユーザーの位置とフィードの
$.YQL = function(query, callback) {
var encodedQuery = encodeURIComponent(query.toLowerCase()),
url = 'http://query.yahooapis.com/v1/public/yql?q=' + encodedQuery + '&format=json&callback=?';
$.getJSON(url, callback);
};
$.YQL("SELECT * FROM weather.forecast WHERE location = 93065", function(data){
var w = data.query.results.channel;
var d = new Date();
var curr_hour = d.getHours();
var dn = (curr_hour < 18 && curr_hour > 4 ? 'd' : 'n');
var weatherImage = "http://l.yimg.com/a/i/us/nws/weather/gr/" + w.item.condition.code + dn + ".png";
var weatherIcon = "http://l.yimg.com/a/i/us/nws/weather/gr/" + w.item.condition.code + "s.png";
$('.weatherImage').html("<img src='" + weatherImage + "' />");
$('.weatherTemp').html(w.item.condition.temp + "°");
$('.weatherText').html(w.item.condition.text);
$(this).everyTime('300s', function(){
var w = data.query.results.channel;
var d = new Date();
var curr_hour = d.getHours();
var dn = (curr_hour < 18 && curr_hour > 4 ? 'd' : 'n');
var weatherImage = "http://l.yimg.com/a/i/us/nws/weather/gr/" + w.item.condition.code + dn + ".png";
var weatherIcon = "http://l.yimg.com/a/i/us/nws/weather/gr/" + w.item.condition.code + "s.png";
$('.weatherImage').html("<img src='" + weatherImage + "' />");
$('.weatherTemp').html(w.item.condition.temp + "°");
$('.weatherText').html(w.item.condition.text);
});
}).appendTo('.pin-up-weather');
きれいではありませんが、その短期的な解決策:
これは私が使用しているものです。きわめて動的に動作するカスタムメイドの天気フィードの経験がある人はいますか?
天気予報は、ユーザーが閲覧している場所に基づいて更新したいと思っていましたが、可能ではありません。私はGoogleのGeolocation APIを見ていましたが、サービスはなく、マップapiが引き継いだものもありましたが、それでもわかりませんでした。
もし私がうまくいけば、私は自分のプロフィールで何を指定したのかに応じて、データベースから場所を取得することができます。
おかげ
場所のWOEIDを確認するには、answer =の投稿を参照してください。> http://stackoverflow.com/questions/1822650/yahoo-weather-api-woeid-retrieval – Neil