Nike+iPod API

A few people have asked about how I pulled some of the URLs for communicating with the Nike servers. It all started with the WordPress plugin which revealed the first pair of URLs we needed and how to utilize them.

https://www.nike.com/nikeplus/v1/services/app/external_profile_login.jhtml?
    login=$username&password=$password&locale=en_us


and

http://www.nike.com/nikeplus/v1/services/app/getuserdata.jhtml



The first URL is called and returns this XML structure and a cookie needed to call the second URL.

<plusService>
<status>success</status>
</plusService>


The second URL returns an XML structure that contains all the basic run data:

<?xml version="1.0" encoding="UTF-8"?>
<plusService>
    <status>success</status>
    <user>
        <gender>male</gender>
        <email>ernieoporto@yahoo.com</email>
        <postalCode>08844</postalCode>
        <state>NJ</state>
        <city>Hillsborough</city>
        <country>US</country>
    </user>
    <userTotals>
        <totalDistance>54.8335</totalDistance>
        <totalDuration>26698062</totalDuration>
        <totalRuns>14</totalRuns>
        <totalCalories>4476</totalCalories>
    </userTotals>
    <userOptions>
        <screenName><![CDATA[shokk]]></screenName>
        <distanceUnit>mi</distanceUnit>
        <dateFormat>MM/DD/YY</dateFormat>
        <startWeek>Su</startWeek>
        <avatar>2</avatar>
        <powerSong>
            <artist><![CDATA[Korn]]></artist>
            <album><![CDATA[Untouchables]]></album>
            <title><![CDATA[Wake Up Hate]]></title>
        </powerSong>
    </userOptions>
</plusService>


As you can see, it has all my basic info, even as to which avatar I picked for my account. It is this data we use to make the info you see in the current sidebar. Next, knowing that the Nike+ iPod widgets published for use with Yahoo Widgets could get challenges and goal data, I downloaded them, grepped the files for “http” and got a bunch of results which yielded these URLs:

https://www.nike.com/nikeplus/v1/services/widget/generate_pin.jhtml
https://www.nike.com/nikeplus/v1/services/widget/generate_token.jhtml
http://www.nike.com/nikeplus/v1/services/widget/check_version.jhtml
http://www.nike.com/nikeplus/v1/services/widget/getchallengedetail.jhtml
http://www.nike.com/nikeplus/v1/services/widget/getchallengesfor_user.jhtml
http://www.nike.com/nikeplus/v1/services/widget/goal_list.jhtml
http://www.nike.com/nikeplus/v1/services/widget/token_login.jhtml
http://www.nike.com/nikeplus/?token="+token
http://www.nike.com/nikeplus/?l=goals,"+challengeID+"&token="+token
http://www.nike.com/nikeplus/?l=challenges,"+challengeID+"&token="+token


and knowing that the https URLs were authenticated with login=USERNAME&password=PASSWORD&locale=en_us
(be sure to replace my en_us locale with your own locale), then I could make use of the above to grab data. Except if you look a the first two URLs we made use of, “app” is in place of “widget”. So with a little substition, we get an XML response that we can parse to get runIDs, challengeIDs, and goalIDs.

The next mystery is how to get and make use of the TOKEN. After much fooling around with the above URLs, I realized that the generate_token and generate_pin were really doing the same thing. So that this call

https://www.nike.com/nikeplus/v1/services/app/generate_pin.jhtml?login=USERNAME&
    password=PASSWORD+generate\_pin.jhtml&hl=en&gl=us&ct=clnk&cd=2

generated something like this structure:

<plusService>
<status>success</status>
<pin>02A3E14F-09E7-7230-3C43-4BAF31FC5A33</pin>
</plusService>

and 02A3E14F-09E7-7230-3C43-4BAF31FC5A33 turns out to be the token/pin that can be used in the bottom three URLs to take you to the Flash pages showing the challenge, goal, and run data. This is the equivalent of the username and password pair for getting you onto the nikeplus.com site. And no, that is not my real real PIN. =) This seems to really only be useful for the runner, and not very interesting for anyone the runner is sharing with.

The rest of the work is parsing and processing the various results of the authenticated URLs. Note that the nikeplus.com site has been undergoing some serious growing pains after the 2006 holiday season and has been a bit flaky. For this reason, the caching ability of the nikeplus script is very important. And even now they have chosen to update their widgets and the authentication URL is returning “login from locale not allowed” while the widgets themselves say “We’re actively restoring the nikeplus Yahoo Widgets. Your patience is trophy-worthy. Check back soon! Upgrade”. Their community boards are full of complaints about this, but hopefully they will get past this problem.

On their site they have a new Resolutions Flash widget for web sites that makes use of the same ID info for challenges and goals. As you can see, I’m very much behind on my goal.

http://www.nike.com/nikeplus/v1/swf/scrapablewidget/goalresolution.swf

In my next installment, we’ll go over what the data for run, goal, and challenges XML looks like.

Advertisements

2 thoughts on “Nike+iPod API

Comments are closed.