Skip to content

Instantly share code, notes, and snippets.

@daniilr
Created April 19, 2015 13:08
Show Gist options
  • Save daniilr/1340c8109808180fa7bd to your computer and use it in GitHub Desktop.
Save daniilr/1340c8109808180fa7bd to your computer and use it in GitHub Desktop.
XML RPC mockup
from SimpleXMLRPCServer import SimpleXMLRPCServer
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
class RequestHandler(SimpleXMLRPCRequestHandler):
rpc_paths = ('/interface/xmlrpc',)
def getchallenge(self, *args, **kwargs):
return {'expire_time': 1428058824, 'challenge': 'c0:1428055200:3564:60:FXaXilbELW4DxMdKU5HB:5be271f05e6c2c9dd6b9665f31146ee2', 'auth_scheme': 'c0', 'server_time': 1428058764}
def login(self, *args, **kwargs):
return {'username': 'r_daniil', 'identity_type': '', 'identity_value': '', 'userid': 44563971, 'is_validated': 1, 'friendgroups': [{'id': 6, 'sortorder': 50, 'public': 0, 'name': 'Mobile View'}, {'id': 4, 'sortorder': 50, 'public': 0, 'name': 'School'}, {'id': 1, 'sortorder': 50, 'public': 0, 'name': 'Family'}, {'id': 3, 'sortorder': 50, 'public': 0, 'name': 'Online Friends'}, {'id': 2, 'sortorder': 50, 'public': 0, 'name': 'Local Friends'}, {'id': 5, 'sortorder': 50, 'public': 0, 'name': 'Work'}], 'identity_display': '', 'usejournals': [], 'identity_url': '', 'fullname': 'r_daniil'}
def main():
server = SimpleXMLRPCServer(("localhost", 8000), requestHandler=RequestHandler)
server.register_introspection_functions()
server.register_function(getchallenge, "LJ.XMLRPC.getchallenge")
server.register_function(getchallenge, "LJ.XMLRPC.login")
server.serve_forever()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment