PHP Nike+iPod stats
December 29, 2006 – 12:16 amA while back I got a Nike+iPod attachment for my iPod. I really love the stats the Nike web site gives you, but there is really no good way to share that data. Nike came out with some desktop widgets for Yahoo Widgets, but you still can’t easily share that with others. However, today I saw a story about a Wordpress plugin that did exactly this. The catch is that it uses PHP5 and I am on PHP4, so I could not port it over. I did a bit of Googling and found that the two URLs the script made use of was all I needed. With some creative CURL use, I wrote a script from scratch that gathered the XML data. The output can be seen on the right hand side of this blog. As you can tell, even though I got it a while back, I have not done as much running as I would have liked. Recent karate-related ankle and knee injuries have kept me from pursuing this as much as I’d have liked, but I’m hoping to pick it up again, despite the cold weather. A recent subscription to Runner’s World has me enthusiastic about running again, so hopefully those stats will go up.
You can pick up a copy of the nikeplus.php version 1.0 PHP script here for use on your own site. Be sure to rename the nikeplus.pht file to nikeplus.php. You can use something like this to place it as a static HTML text object in the sidebar of the CMS of your choice:
<iframe width=”200″ style=”border:none;” src=”http://www.site.com/nikeplus.php”></iframe>
Wishlist/Coming enhancements:
- Cached data for quick response and reduced calls to Nike servers.
- Goals and Challenges data.
- Red and green theme to match the Nikeplus.com site.
- RSS link to the actual run data.
If you have an enhancement or some code to add, feel free to email me or leave a comment!
Update 12/31/06: – I’ve posted version 1.1. Thanks to Beth Terry who pointed out in the comments below that those who have run more than 1,000 minutes or miles or whatever I was formatting with number_format would have a comma in it and thus mess up the stats. I’ve moved all number formatting into the print statements so that stats will be correctly displayed.
Update 1/3/07: – Version 1.2 is posted thanks to Eric Byers who contributed code to add caching. I’ll try to pretty it up and add the RSS, Goals, and Challenges data next.
Sphere: Related Content