|
|
@ -79,16 +79,16 @@ def setup_webhook(api):
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/auth')
|
|
|
|
@app.route('/twitter/auth')
|
|
|
|
def auth():
|
|
|
|
def twitter_auth():
|
|
|
|
handler = tweepy.OAuthHandler(consumer_key, consumer_secret, callback_url)
|
|
|
|
handler = tweepy.OAuthHandler(consumer_key, consumer_secret, callback_url)
|
|
|
|
url = handler.get_authorization_url()
|
|
|
|
url = handler.get_authorization_url()
|
|
|
|
flask.session['request_token'] = handler.request_token
|
|
|
|
flask.session['request_token'] = handler.request_token
|
|
|
|
return flask.redirect(url)
|
|
|
|
return flask.redirect(url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/callback')
|
|
|
|
@app.route('/twitter/callback')
|
|
|
|
def callback():
|
|
|
|
def twitter_callback():
|
|
|
|
request_token = flask.session['request_token']
|
|
|
|
request_token = flask.session['request_token']
|
|
|
|
del flask.session['request_token']
|
|
|
|
del flask.session['request_token']
|
|
|
|
handler = tweepy.OAuthHandler(consumer_key, consumer_secret, callback_url)
|
|
|
|
handler = tweepy.OAuthHandler(consumer_key, consumer_secret, callback_url)
|
|
|
@ -107,8 +107,8 @@ def callback():
|
|
|
|
return 'Success', 200
|
|
|
|
return 'Success', 200
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/webhook', methods=['GET'])
|
|
|
|
@app.route('/twitter/webhook', methods=['GET'])
|
|
|
|
def webhook_get():
|
|
|
|
def twitter_webhook_get():
|
|
|
|
crc = flask.request.args.get('crc_token')
|
|
|
|
crc = flask.request.args.get('crc_token')
|
|
|
|
if not crc:
|
|
|
|
if not crc:
|
|
|
|
return 'Invalid request', 403
|
|
|
|
return 'Invalid request', 403
|
|
|
@ -116,8 +116,8 @@ def webhook_get():
|
|
|
|
return dict(response_token='sha256={0}'.format(base64.b64encode(digest).decode())), 200
|
|
|
|
return dict(response_token='sha256={0}'.format(base64.b64encode(digest).decode())), 200
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/webhook', methods=['POST'])
|
|
|
|
@app.route('/twitter/webhook', methods=['POST'])
|
|
|
|
def webhook_post():
|
|
|
|
def twitter_webhook_post():
|
|
|
|
def verify():
|
|
|
|
def verify():
|
|
|
|
signature = flask.request.headers.get('X-Twitter-Webhooks-Signature')
|
|
|
|
signature = flask.request.headers.get('X-Twitter-Webhooks-Signature')
|
|
|
|
if not signature:
|
|
|
|
if not signature:
|
|
|
|