Tim Hibbard

CEO for EnGraph software
posts - 629 , comments - 1703 , trackbacks - 459

My Links


Add to Google

Tag Cloud


EnGraph Blogs




Working with WeatherBug API

I talked earlier about integrating WeatherBug data into Where's Tim. Chris Sloop has been a lot of help and was even nice enough to include Where's Tim on the WeatherBug's API example page. He requested that I share some code, so here it is:

Basically, to consume WeatherBug's API, I:
1) Make a call to the Where's Tim webservice
2) Parse the zipcode out of the .Place property of the GPSData structure
3) Pass the zipcode into a function that builds the REST url
4) Load the url into a System.Data.DataSet using the .ReadXML function
5) Pass that DataSet into my WeatherInfo structure that takes a DataSet as a constructor

Code to get location and parse zipcode:

Public Function GetTimsWeather() As WeatherInfo
CurData As GPSData = GetTimsLocation()
      Dim ZipCode As String = CurData.Place.Remove(0, CurData.Place.Length - 5)
      Return GetWBInfo(ZipCode)
   Catch ex As Exception
      Return Nothing
   End Try
End Function

Code to build URL, load DataSet, and construct structure:
Private Function GetWBInfo(ByVal ZipCode As String) As WeatherInfo
      Dim url As String = "http://[myCode].api.wxbug.net/getlivecompactweather.aspx?acode=[myCode]&zipcode=" & ZipCode
      Dim DS As New System.Data.DataSet
      Dim RV As New WeatherInfo(DS, ZipCode)
      Return RV
   Catch ex As Exception
      Return Nothing
   End Try
End Function

Code of WeatherInfo structure constructor:
Public Sub New(ByVal DS As System.Data.DataSet, ByVal ZipCode As String)
      _temp = DS.Tables("temp").Rows(0).Item("temp_Text")
      _rain = DS.Tables("rain-today").Rows(0).Item("rain-today_Text")
      _wind = DS.Tables("wind-speed").Rows(0).Item("wind-speed_Text")
      _winddirection = DS.Tables("weather").Rows(0).Item("wind-direction")
      _zipcode = ZipCode
      _weblink = "http://web.live.weatherbug.com/Common/home.aspx?zip=" & _zipcode
   Catch ex As Exception
   End Try
End Sub

Also, the WeatherBug API is now listed ProgrammableWeb.com's API list and so is the Where's Tim webservice

I've also integrated the WeatherBug data into Where's Tim Mobile.

Print | posted on Friday, January 13, 2006 7:51 AM |



# re: Working with WeatherBug API

In order to includ ethese methods do i need to integrate any dll in my application if so if you could provide me the dll then it will be a great help to me.
7/21/2009 1:42 AM | vamsi

# re: Working with WeatherBug API

Tim make the integration with his application which, probably, uses certain libraries. For your specific application, take the integration part and just use it like that, for your custom app, said bijuterii din argint.
8/2/2011 7:56 AM | Georgy

# re: Working with WeatherBug API

I am workin on similar API,
is there any way i can decide that the wather is sunny, or partially clody, or rainy or clody etc so that i can put dynamic weather images based on that?
9/17/2011 4:16 PM | amul

# re: Working with WeatherBug API

hi can i get lightning alert.(lattitude,longittude,PeakAmplitude,date and time) of lightning...?if any one know reply me..
5/13/2013 9:12 AM | pullareddy
Post A Comment

Powered by: