diff --git a/README.md b/README.md
index 00e4b77..7662df0 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,7 @@ Features
* Facebook API
* Google+ API
* Dropbox API
+ * Foursquare API
@@ -246,12 +247,28 @@ Getting API Keys
5. Give your app a name and click the **Create app button**.
6. You will be redirected to the app console:
* Under **Redirect URIs** specify the URL to be redirected after authentication is complete (e.g ```http://locahost:8000/home```) and click **add**.
- * Copy you ```App key``` and ```App secret```.
+ * Copy your ```App key``` and ```App secret```.
7. Under ```settings.py``` change the following values:
* ```DROPBOX_APP_ID = your_app_id```
* ```DROPBOX_APP_SECRET = your_app_secret```
+
+
+1. Register and account on [Foursquare.com](https://foursquare.com).
+2. Navigate to [Foursquare For Developers](https://developer.foursquare.com).
+3. From the top menu bar select **My Apps** and you will be redirected to the app dashboard.
+4. Hit **Create a New App**:
+ * Give your app a name.
+ * Under **Download / welcome page url**, specify your app main url (e.g ```http://www.localhost:8000```).
+ * Under **Redirect URI**, specify the URL to be redirected after authentication is complete (e.g ```http://locahost:8000/home```) and click **add**.
+ * Scroll all the way to the botttom and hit **Save Changes**.
+5. From the App page you were redirected to, copy your ```App key``` and ```App secret```.
+6. Under ```settings.py``` change to following values:
+ * ```FOURSQUARE_APP_ID = your_client_id```
+ * ```FOURSQUARE_APP_SECRET = your_app_secret```
+
+
diff --git a/hackathon_starter/hackathon/models.py b/hackathon_starter/hackathon/models.py
index fa39915..a5252d6 100644
--- a/hackathon_starter/hackathon/models.py
+++ b/hackathon_starter/hackathon/models.py
@@ -83,7 +83,7 @@ class FacebookProfile(models.Model):
time_created = models.DateTimeField(auto_now_add=True)
profile_url = models.CharField(max_length=50)
access_token = models.CharField(max_length=100)
-
+
class GoogleProfile(models.Model):
user = models.ForeignKey(User)
google_user_id = models.CharField(max_length=100)
@@ -95,4 +95,11 @@ class DropboxProfile(models.Model):
user = models.ForeignKey(User)
dropbox_user_id = models.CharField(max_length=100)
time_created = models.DateTimeField(auto_now_add=True)
- access_token = models.CharField(max_length=100)
\ No newline at end of file
+ access_token = models.CharField(max_length=100)
+
+
+class FoursquareProfile(models.Model):
+ user = models.ForeignKey(User)
+ foursquare_id = models.CharField(max_length=100)
+ time_created = models.DateTimeField(auto_now_add=True)
+ access_token = models.CharField(max_length=100)
diff --git a/hackathon_starter/hackathon/scripts/foursquare.py b/hackathon_starter/hackathon/scripts/foursquare.py
new file mode 100644
index 0000000..a436b08
--- /dev/null
+++ b/hackathon_starter/hackathon/scripts/foursquare.py
@@ -0,0 +1,102 @@
+import simplejson as json
+import urllib
+import requests
+
+
+############################
+# FOURSQUARE API CONSTANTS #
+############################
+AUTHORIZE_URL = 'https://foursquare.com/oauth2/authenticate'
+ACCESS_TOKEN_URL = 'https://foursquare.com/oauth2/access_token'
+REDIRECT_URL = 'http://localhost:8000/hackathon'
+
+
+class FoursquareOauthClient(object):
+ '''
+ Pytohn client for Foursquare API
+ '''
+
+ access_token = None
+
+ def __init__(self, client_id, client_secret):
+ '''
+ Parameters:
+ client_id: String
+ - The client id from the registering app on Facebook
+ client_secret: String
+ - The client secret from the registering app on Facebook
+ '''
+ self.client_id = client_id
+ self.client_secret = client_secret
+
+
+
+ def get_authorize_url(self):
+ '''
+ Obtains authorize url link with given client_id.
+
+ Returns:
+ authURL: String
+ - The authorization url.
+
+ '''
+ authSettings = {'client_id': self.client_id,
+ 'response_type': 'code',
+ 'redirect_uri': REDIRECT_URL}
+
+ params = urllib.urlencode(authSettings)
+
+ return AUTHORIZE_URL + '?' + params
+
+
+
+ def get_access_token(self, code):
+ '''
+ Obtains access token.
+
+ Parameters:
+ code: String
+ - The code is retrieved from the authorization url parameter
+ to obtain access_token.
+ '''
+
+ authSettings = {'client_id': self.client_id,
+ 'client_secret': self.client_secret,
+ 'grant_type': 'authorization_code',
+ 'redirect_uri': REDIRECT_URL,
+ 'code': code}
+
+ params = urllib.urlencode(authSettings)
+ response = requests.get(ACCESS_TOKEN_URL + '?' + params)
+
+ if response.status_code != 200:
+ raise(Exception('Invalid response,response code: {c}'.format(c=response.status_code)))
+
+ self.access_token = response.json()['access_token']
+
+
+ def get_user_info(self, api_version='20140806'):
+ '''
+ Obtains user information.
+
+ Parameters:
+ api_version: string
+ - The API version you would use. This parameter is mandatory by Foursquare.
+
+ Returns:
+ content: Dictionary
+ - A dictionary containing user information.
+ '''
+ USER_INFO_API_URL = 'https://api.foursquare.com/v2/users/self'
+
+ authSettings={'v':api_version,
+ 'oauth_token': self.access_token}
+
+ params = urllib.urlencode(authSettings)
+
+ response = requests.get(USER_INFO_API_URL + '?' + params)
+
+ if response.status_code != 200:
+ raise(Exception('Invalid response,response code: {c}'.format(c=response.status_code)))
+
+ return response.json()['response']['user']
diff --git a/hackathon_starter/hackathon/templates/hackathon/api_examples.html b/hackathon_starter/hackathon/templates/hackathon/api_examples.html
index 7b30eee..3ddc3e1 100644
--- a/hackathon_starter/hackathon/templates/hackathon/api_examples.html
+++ b/hackathon_starter/hackathon/templates/hackathon/api_examples.html
@@ -17,12 +17,13 @@
-
+
-
-
+
+
+