PHP Nike+ Stats Script

January 3rd, 2007

I was looking for a PHP script to pull in stats so I could display them on my blog. It turns out Ernie Oporto had modified a script that was used for a Wordpress widget and put it up for download. One issue was that it did not do caching.

I took a few minutes and added caching on to it, it’s pretty simple right now, just saving a file to a tmp directory. That seems to keep the hitting of the Nike+ website down to a minimum.

I have more plans for this also:
— Make caching more robust, this one may not work on Windows servers
— Change the average time to be in minutes:seconds instead of decimal
— Allow user to customize formatting
— Functionize/Clean-up Script

I just took a few minutes on this, so there may be some issues, please add a comment and I’ll try to address it.

PHP Nike+ Stats v1.2 [Download]
You will need to save file as php instead of phps (which is for display).

Update:
I now present to you version 1.2.1. You can see a working version in my right sidebar.
— Rewrote code to easier add goals/challenges later
— Change Avg. Pace time seconds from decimal to roman
— Added more debugging info
— Few small minor changes

PHP Nike+ Stats v1.2.1 [Download]

Second Update: I haven’t really spent any time working on this lately, but Ernie has it updated so it is working now. Check it out here.

17 responses

  1. Ernie Oporto comments:

    Works like a charm. I’ve updated it on the site. Will work on this some more this weekend anyway. =)

  2. Eric comments:

    Excellent, I am working on it right now also, so I’ll ping you back when I have it updated more.

    You want to throw it up on sourceforge or something and we both can work on it? Or would you rather just maintain it?

  3. Marshall comments:

    Is there a time period listed somewhere? Like you’ve done 12 runs over how long? 12 months?

  4. Ernie Oporto comments:

    The Nike+ site doesn’t actually give you that info in the XML.

  5. Eric comments:

    Ernie’s right…

    You could do a couple of different things though. One is ask for a user specified start date and do some averages. The other I’m sure there is or will be a way to get all the run data, so you could figure it out from there…but that’s down the road.

  6. Ernie Oporto comments:

    I’ve been successful in pulling data from the Nikeplus.com site about challenges and goals in XML so I will be working that into the script Saturday. It works very much like what we have been doing, so it will be very much cut and paste with a little additional logic.

  7. Sarah comments:

    I never cease to be amazed that you can geek-a-tize something as simple as running - but I guess if that’s what keeps you going, and at least you’re passionate about something.

  8. Ernie Oporto comments:

    Yeah, I think if the tech encourages someone to get into running, then it was worth the effort.

  9. forevervain · Nike+ iPod - Initial Review pings back:

    [...] This data was just pulled off the Nike site for me by the justdoingit people (only they don’t have decimals for tenths of miles apparently), but there are also wordpress plugins and the like that you can use. I’m using this one by Eric Byers in my sidebar. [...]

  10. Jim comments:

    I can’t get the ipod download to wkrk today and it’s been working. Say’s “login from locale not allowed’ any ideas?

  11. Eric comments:

    Jim, I saw that last night also, it appears Nike changed their script about 2 days ago (my runs haven’t been updated since then).

    Hopefully there is a work around, but I haven’t even looked at it (besides finding the same error).

  12. thom comments:

    Same issue; login from locale not allowed.

    justdoit still works, though. They must have a workaround

  13. Eric comments:

    Ernie has it working again, check out his blog for the download.

  14. Dermo comments:

    This is maybe cheeky but have you any plans to share the cool changes for sowing goals and previous runs?

  15. Eric comments:

    Well on the right hand side I’m actually using a combination of my script, and someone else’s. Check out Ernie’s site for the actual code for mine, and then there is a wordpress widget that does it, and you can find how to do all of it in there.

  16. Dermo comments:

    Cheers Eric
    I’m using MT ofr my blog but I’ll have a look at the WP plugin and see if I can somehow use the script. Although I haven’t a clue about programming anything more than XHTML and CSS. I really should learn someday.
    Enjoy your race tomorrow!

  17. kilo india tango · Nike+ iPod - Initial Review pings back:

    [...] apparently), but there are also wordpress plugins and the like that you can use. I’m using this one by Eric Byers in my [...]

Leave a comment