Skip to content

Instantly share code, notes, and snippets.

@cloverstd
Last active August 29, 2015 14:06
Show Gist options
  • Save cloverstd/a16c50b54d89ad47441c to your computer and use it in GitHub Desktop.
Save cloverstd/a16c50b54d89ad47441c to your computer and use it in GitHub Desktop.
IFTTT webhook by Python with Tornado
#!/usr/bin/env python
# encoding: utf-8
from tornadorpc.xml import XMLRPCHandler
import tornado.ioloop
import tornado.httpserver
import tornado.web
class MT(object):
def supportedMethods(self, *args, **kwargs):
"""Just for wordpress blog verification"""
return ['metaWeblog.getRecentPosts']
class MetaWeblog(object):
def getRecentPosts(self, blogid, username, password, numberOfPosts):
"""send a blank blog response"""
"""this also makes sure that the channel is never triggered"""
return []
def newPost(self, blogid, username, password, content, publish):
print content
# handle content
return 1
class Handler(XMLRPCHandler):
mt = MT()
metaWeblog = MetaWeblog()
app = tornado.web.Application([('/xmlrpc.php', Handler)], debug=True)
if __name__ == '__main__':
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(8888)
tornado.ioloop.IOLoop.instance().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment