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
- Create an event channel in your Kynetx (SquareTag) account labeled "Foursquare Checkins" using KDK (Kynetx Developer Kit)
- 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. - Create a
foursquare
ruleset and install it in your account using KDK:- Write a rule called
process_fs_checkin
that listens for thefoursquare:checkin
event. - The rule should store the
venue name
,city
,shout
, andcreatedAt
event attributes in entity variables. - Write a rule called
display_checkin
that shows the results in SquareTag. - You will need to register the ruleset and install it in your SquareTag account.
- Write a rule called
- Test the ruleset by using
curl
or your browser to call the ESL you created above. You will have to give it event attributes. - 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
. - Use the Foursquare test button to raise the event from Foursquare. You should see results on SquareTag.
- Checkin with Foursquare on your phone. You should see the result in your SquareTag application.
Bonus
- Change your SquareTag account to allow the user to authorize their own account using OAuth.
- Create an ECI and configure the Push URL in the user's Foursquare account
- 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.