OSDN Git Service

line web hook ok
authoryamat0jp <yamat0jp@yahoo.co.jp>
Fri, 7 Sep 2018 09:18:11 +0000 (18:18 +0900)
committeryamat0jp <yamat0jp@yahoo.co.jp>
Fri, 7 Sep 2018 09:18:11 +0000 (18:18 +0900)
test code

bot.py

diff --git a/bot.py b/bot.py
index 9abfa01..33860a9 100644 (file)
--- a/bot.py
+++ b/bot.py
@@ -56,13 +56,11 @@ class WebHookHandler(tornado.web.RequestHandler):
         return ans
             
     def post(self):
-        self.write('hello world')
-    '''
         header = json.load(self.request.headers)
         body = json.load(self.request.body)
-        hash = hmac.new(header['X-LINE-SIGNATURE'].encode('utf-8'),
+        hashid = hmac.new(header['X-LINE-SIGNATURE'].encode('utf-8'),
             body.encode('utf-8'), hashlib.sha256).digest()
-        signature = base64.b64encode(hash)
+        signature = base64.b64encode(hashid)
         try:
             events = webhook.parse(body, signature)
         except InvalidSignatureError:
@@ -74,7 +72,6 @@ class WebHookHandler(tornado.web.RequestHandler):
                     event.reply_token,
                     TextSendMessage(text=self.main(event.Message.text))
                 )
-    '''
         
 class DummyHandler(tornado.web.RequestHandler):
     def get(self):