I started using Yahoo's free weather API to get the weather data I need, but it seems each time I request a city weather data there is a chance that either I get updated data or old data from back to 1 to 8 days.
Here is a simple URL which I make my request with: Click here to see a sample request
The YQL query is simple, which requests the weather data for New York city:
select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="New York")
But each time I refresh that URL, I might get a completely different result. for example I did refresh it right now a couple times (Now is 13th of November 2015, around 22:45 GMT time) and here are some results I got in the query.results.channel.item.condition.date
part:
"date":"Fri, 13 Nov 2015 4:49 pm EST"
"date":"Thu, 12 Nov 2015 2:13 am EST"
"date":"Wed, 11 Nov 2015 1:49 am EST"
"date":"Fri, 13 Nov 2015 1:49 am EST"
This is very wired, how am I supposed to get current weather data like this when the API returns weather data for random dates each time I make a request?
Am I doing something wrong or missing something here?
Notes:
Updates:
Yahoo dev's replied on twitter saying that they are investigating this issue. You can follow it up and upvote (for speeding the process) it here:
https://yahoo.uservoice.com/forums/207813/suggestions/10740099
I have used the Yahoo Weather API XML format for years and noticed in that last couple of weeks this new bug. I tried to report the bug to https://developer.yahoo.com/weather/support but get a 404 page not found. I decided to parse the returned date if equal to current date to continue if not equal to re-call sub. this way I always get current weather but unfortunately that's a lot of unnecessary traffic / request maybe YDN will realize and fix. but without being able to report I don't know. I know this is not a fix but more a Band-Aid good luck!
Private Sub btnWeather_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWeather.Click
If InternetConnection() = False Then
MsgBox("No internet connection!", vbExclamation, "Oops!")
Exit Sub
Else
'MsgBox("Internet connection detected!", vbInformation, "Huray!")
btnWeather.Enabled = False
lblWorking.Text = "Working ..."
tbTries.Text = "1"
Try
Dim t As New clsWeather(Format(Me.TxtBoxZIP.Text), "f")
lblTodaysDate.Text = FormatDateTime(Now.Date, DateFormat.ShortDate)
tbHigh.Text = t.high & "°"
lblCity.Text = TxtBoxZIP.Text & " Weather "
tbLow.Text = t.Low & "°"
tbDay.Text = t.day
tbDate.Text = t.date1
tbCurrenttemp.Text = t.currenttemp & "°"
tbCurrentCode.Text = t.currentcode
tbForcastCode.Text = t.ForcastCode
tbSunrise.Text = t.Sunrise
tbSunset.Text = t.Sunset
tbWind.Text = CInt(Val(t.Wind)) & " mph"
tbHumidity.Text = CInt(Val(t.humidity))
imgWeather.Image = Image.FromFile(t.GetImage)
CodeName()
If t.currenttemp < 85 And t.currenttemp > 45 Then
lblFeelsLike.Text = ""
tbFeelsLike.Text = ""
End If
If t.currenttemp > 85 Then
lblFeelsLike.Text = "Heat Index:"
Dim Temp = t.currenttemp
Dim RH = CInt(Val(t.humidity))
tbFeelsLike.Text = (-42.379 + 2.04901523 * Temp) + (10.14333127 * RH) - (0.22475541 * Temp * RH) - (0.00683783 * Temp * Temp) - (0.05481717 * RH * RH) + (0.00122874 * Temp * Temp * RH) + (0.00085282 * Temp * RH * RH) - (0.00000199 * Temp * Temp * RH * RH)
Dim num As Decimal = CType(tbFeelsLike.Text, Decimal)
Me.tbFeelsLike.Text = String.Format("{0:n0}", num)
tbFeelsLike.Text = tbFeelsLike.Text & "°"
End If
If t.currenttemp < 45 Then
lblFeelsLike.Text = "Wind Chill:"
tbFeelsLike.Text = CInt(Val(t.Chill)) & "°"
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
Dim day As String = DateTime.Now.ToString("dd")
If day = tbDate.Text = True Then
tbDate1.Text = tbDate.Text
btnWeather.Enabled = True
lblWorking.Text = ""
Else
btnWeather_Click(sender, e)
tbTries.Text = tbTries.Text + 1
End If
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With