Created
October 26, 2011 00:09
-
-
Save mehdimehdi/1314876 to your computer and use it in GitHub Desktop.
User query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FoursquareUserToken(models.Model): | |
key = models.CharField(max_length=200,null=True) | |
secret = models.CharField(max_length=200) | |
status = models.CharField(max_length=10,default="ACT") | |
user = models.ForeignKey(User,null=True) | |
date_updated = models.DateTimeField(auto_now=True,null=True) | |
date_created = models.DateTimeField(auto_now_add=True) | |
def query(self): | |
url = 'https://api.foursquare.com/v2/users/self' | |
params = {'oauth_token': self.secret} | |
url += '?' + urllib.urlencode(params) | |
response = simplejson.load(urllib.urlopen(url)) | |
if not response: | |
raise Exception() | |
if 'error' in response: | |
raise Exception() | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment