Subscriptions

CREATING, UPDATING, AND DELETING SUBSCRIPTIONS

Nike+ currently creates, updates, and deletes subscriptions for developers when they provide a callback URL (and optionally, a verify token).

Nike+ uses a subscription to register an app and enable it to receive notifications when an Activity related to a user of the app is created, updated, or deleted.

Subscriptions can be verified using the optional verify_token property.

 Note:  You can create a subscription even after users are connected to an app. When Nike+ verifies the subscription, the Webhooks service can then send notifications to any connected subscribed apps for Activities associated with the user that are created, updated, or deleted after the subscription takes effect.

SUBSCRIPTION FIELDS

Name
Type
Required?
Description
callback_url String (URI format RFC 3986) Yes
The URL that will receive an initial GET request when Nike+ verifies a subscription and then POST requests from the Webhooks service.
verify_tokenString String No An optional arbitrary string used to confirm the callback_url is valid and verify that notifications are from Nike+.

CREATING THE CALLBACK URL

A Webhooks subscription requires a callback URL that is accessible to Nike+ servers. The callback URL must be able to accept:

  • GET requests from the Webhooks service to verify subscriptions.
  • POST requests from the Webhooks service when an Activity is created, changed, or deleted.

Note:  Developers should provide a verify token if they want Nike+ to include it in any POST notifications to verify that the POST is from Nike+ (see NOTIFICATIONS for more information).

VERIFYING A SUBSCRIPTION

Once you have provided Nike+ with a callback URL (and optionally, a verify token), the Webhooks service will make a GET call to the callback_url with a query string that includes a hub_challenge (and the hub_verify_token property if you provided a verify_token) to verify that the callback URL is valid.

 The server with the callback URL must then:

  1. Verify that the hub_verify_token is correct if you provided a verify_token to Nike+ when setting up the subscription (the hub_verify_token should match the verify_token you supplied).
  2. Send a 200 OK response with the hub_challenge value in the body to the Webhooks service.

SUBSCRIPTION VERIFICATION FIELDS

Name
Type
Required?
Description
hub_mode String
Yes
The value will always be “SUBSCRIBE”
hub_challenge String Yes A random string that the callback URL will need to echo back in the body of the response to confirm the subscription
hub_verify_token String No The optional verify_token value you specified when you created the subscription

SAMPLE GET REQUEST FOR SUBSCRIPTION VERIFICATION

GET{callback_url}?hub_challenge=nbrqv5tkfe4a4g79ehl6asdpa5&hub_mode=SUBSCRIBE&hub_verify_token={verify_token}
Note:  The hub_verify_token is optional and only required if you provided a verify_token when setting up the subscription. See SUBSCRIPTIONS for more information.

SAMPLE GET RESPONSE FOR SUBSCRIPTION VERIFICATION

200 OK

Body: {hub_challange}