Created
February 5, 2012 02:32
-
-
Save skorokithakis/1742112 to your computer and use it in GitHub Desktop.
Revisions
-
skorokithakis created this gist
Feb 5, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ 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()