Created
February 20, 2013 22:03
-
-
Save b1naryth1ef/5000062 to your computer and use it in GitHub Desktop.
Bukkit JSONAPI Python API (That doesnt suck, and uses requests)
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 requests, hashlib, json | |
class API(object): | |
def __init__(self, host, port, user, pw, salt="mysalt"): | |
self.host = host | |
self.port = port | |
self.user = user | |
self.pw = pw | |
self.salt = salt | |
self.url = "http://%s:%s/api/call" % (self.host, self.port) | |
def call(self, method, *args): | |
auth = hashlib.sha256("%s%s%s%s" % (self.user, method, self.pw, self.salt)).hexdigest() | |
kwargs = { | |
"method": method, | |
"key": auth, | |
"args": json.dumps(args) | |
} | |
print requests.get(self.url, params=kwargs).json | |
#x = API("localhost", 20059, "user", "password") | |
#x.call("system.getServerClockDebug") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment