Take a look at this nicely wrapped class - it's basically plug-and-play.