Skip to content

Instantly share code, notes, and snippets.

@skorokithakis
Created February 5, 2012 02:32
Show Gist options
  • Save skorokithakis/1742112 to your computer and use it in GitHub Desktop.
Save skorokithakis/1742112 to your computer and use it in GitHub Desktop.
Badginator Python API
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