Skip to content

Instantly share code, notes, and snippets.

@skorokithakis
Created February 5, 2012 02:32
Show Gist options
  • Select an option

  • Save skorokithakis/1742112 to your computer and use it in GitHub Desktop.

Select an option

Save skorokithakis/1742112 to your computer and use it in GitHub Desktop.

Revisions

  1. skorokithakis created this gist Feb 5, 2012.
    20 changes: 20 additions & 0 deletions __init__.py
    Original 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()