Yeah, I know the world and his dog probably know about these already, but I just discovered them ok?!
They pretty much rock!
The one I was interested in (watch this space) was the weather API. I downloaded the package, fired up Flex Builder, stuck in a Weather Service instance, some event listeners and told it to get me some weather. Which it did! The whole process took me all of 3 minutes. That’s how it should be
Here’s the class I used (the code I used is for Brighton, UK, btw):
package
{
import flash.display.Sprite;
import com.yahoo.webapis.weather.*;
import com.yahoo.webapis.weather.events.*;
public class WeatherTest extends Sprite
{
private var _weatherService:WeatherService;
public function WeatherTest()
{
super();
_weatherService = new WeatherService();
_weatherService.addEventListener(WeatherResultEvent.WEATHER_LOADED, onWeatherLoaded);
_weatherService.addEventListener(WeatherErrorEvent.INVALID_LOCATION, onInvalidLocation);
_weatherService.addEventListener(WeatherErrorEvent.XML_LOADING, onWeatherXMLError);
//get all the weather!
_weatherService.getWeather("UKXX0215", Units.ENGLISH_UNITS);
}
private function onWeatherLoaded(event:WeatherResultEvent):void
{
trace(event.data)
}
private function onInvalidLocation(event:WeatherErrorEvent):void
{
trace(event.data);
}
private function onWeatherXMLError(event:WeatherErrorEvent):void
{
trace(event.data);
}
}
}
Simple huh?
There’s also APIs for Answers, Maps, Search, Upcoming. They’re all well documented and logically laid out. Now get out there and start mashing up those feeds!