Foursquare Checkin Exercise

Objective

In this exercise you will learn how an external service can use the Sky event API to raise events

Preparation

  • Read Chapter 9 of The Live Web. In the exercises that follow, you'll be using Foursquare and it's Push URL feature as your endpoint (i.e. event generator)
  • Create an account at Foursquare if necessary. Enable the developer features. 
  • Install the app on your phone, if necessary
  • The Foursquare developer documentation is here:

Exercise

  1. Create an event channel in your Kynetx (SquareTag) account labeled "Foursquare Checkins" using KDK (Kynetx Developer Kit)
  2. Use the channel ID to formulate an event signal URL (ESL) to raise a foursquare:checkin event. This will become the Foursquare Push URL that you give to Foursquare below.
  3. Create a foursquare ruleset and install it in your account using KDK:
    1. Write a rule called process_fs_checkin that listens for the foursquare:checkin event. 
    2. The rule should store the venue name, city, shout, and createdAt event attributes in entity variables. 
    3. Write a rule called display_checkin that shows the results in SquareTag.
    4. You will need to register the ruleset and install it in your SquareTag account. 
  4. Test the ruleset by using curl or your browser to call the ESL you created above. You will have to give it event attributes.
  5. Create an application at Foursquare, manually go through the OAuth sequence for it, and configure the Push URL to contain the ESL you created above. Remember that Foursquare require https
  6. Use the Foursquare test button to raise the event from Foursquare. You should see results on SquareTag. 
  7. Checkin with Foursquare on your phone. You should see the result in your SquareTag application. 

Bonus

  1. Change your SquareTag account to allow the user to authorize their own account using OAuth. 
  2. Create an ECI and configure the Push URL in the user's Foursquare account
  3. Test by having a friend install your app in their SquareTag account. After authorizing, they should see their checkins in the app. 
Hint: This Dropbox OAuth cookbook example shows how to do OAuth 1.0a. Foursquare uses OAuth 2.0, so it's different, but many of the ideas will be helpful. 

Notes

  • When you create your ESL for Foursquare, you should specify the RID of your Foursquare ruleset (the one that contains the process_fs_checkin rule) using the _rids event attribute. This works around a bug in ruleset versioning with KDK. 

Copyright Picolabs | Licensed under Creative Commons.