Created
February 5, 2012 02:32
-
-
Save skorokithakis/1742112 to your computer and use it in GitHub Desktop.
Badginator Python API
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
import hashlib | |
import urllib, urllib2 | |
class Badginator(object): | |
def __init__(self, game_key): | |
self.game_key = game_key | |
def _sign(self, user_key, achievement_id): | |
return hashlib.sha1(self.game_key + user_key + achievement_id).hexdigest() | |
def unlock_achievement(self, username, user_key, achievement_id): | |
data = { | |
"achievement_id": achievement_id, | |
"signature": self._sign(user_key, achievement_id), | |
} | |
url = "http://www.badginator.net/api/1/user/%s/" % username | |
response = urllib2.urlopen(url, urllib.urlencode(data)) | |
response.read() | |
response.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment