無料の掲示板
Révision | fa99568341509ea30fc47b93ffd2e58e7e4936c9 (tree) |
---|---|
l'heure | 2018-09-25 21:17:39 |
Auteur | 福家 正士 <yamat0jp@yaho...> |
Commiter | 福家 正士 |
test
@@ -1,7 +1,7 @@ | ||
1 | 1 | # -*- coding:utf-8 -*- |
2 | 2 | import os,re,glob |
3 | 3 | from tornado import escape,web,ioloop,httpserver,httpclient |
4 | -import pymongo | |
4 | +import pymongo, urllib | |
5 | 5 | from datetime import datetime,date |
6 | 6 | import json |
7 | 7 | from bson.objectid import ObjectId #don't remove |
@@ -624,7 +624,8 @@ class WebHookHandler(web.RequestHandler): | ||
624 | 624 | te = self.help() |
625 | 625 | else: |
626 | 626 | te = self.main(x) |
627 | - linebot = LineBotApi(self.application.token) | |
627 | + token = self.application.db['params'].find_one({'app':'bot'})['access_token'] | |
628 | + linebot = LineBotApi(token) | |
628 | 629 | linebot.reply_message(event['replyToken'], TextSendMessage(text=te)) |
629 | 630 | |
630 | 631 | class InitHandler(web.RequestHandler): |
@@ -668,10 +669,8 @@ class TokenHandler(web.RequestHandler): | ||
668 | 669 | def get(self): |
669 | 670 | url = 'https://api.line.me/v2/oauth/accessToken' |
670 | 671 | headers = 'application/x-www-form-urlencoded' |
671 | - grant = 'grant_type=client_credentials' | |
672 | - ci = 'client_id='+self.application.id | |
673 | - cs = 'client_secret='+self.application.ch | |
674 | - body = grant+'&'+ci+'&'+cs | |
672 | + data = {'grant_type':'client_credentials', 'client_id':self.application.id, 'client_secret':self.application.ch} | |
673 | + body = urllib.parse.urlencode(data) | |
675 | 674 | req = httpclient.HTTPRequest(url=url,method='POST',headers=headers,body=body) |
676 | 675 | http = httpclient.AsyncHTTPClient() |
677 | 676 | http.fetch(req, callback=self.on_response) |