Skip to content

Commit

Permalink
Merge pull request #8 from fuk/examplefile/fix
Browse files Browse the repository at this point in the history
Changes to messengerbot.py file
  • Loading branch information
Cretezy authored Sep 29, 2016
2 parents 9b4006b + a26f672 commit acf3db3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions examples/messengerbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@
from flask import Flask, request
from pymessenger.bot import Bot
import requests
import ipdb
app = Flask(__name__)
TOKEN = "<access_token>"

ACCESS_TOKEN = ""
VERIFY_TOKEN = ""
bot = Bot(TOKEN)

@app.route("/webhook", methods = ['GET', 'POST'])
@app.route("/", methods = ['GET', 'POST'])

def hello():
if request.method == 'GET':
if (request.args.get("hub.verify_token") == "<token you define during"\
"the verification phase>"):
if (request.args.get("hub.verify_token") == VERIFY_TOKEN):
return request.args.get("hub.challenge")
else:
return 'Invalid verification token'

if request.method == 'POST':
output = request.json
event = output['entry'][0]['messaging']
Expand All @@ -26,7 +30,7 @@ def hello():
bot.send_text_message(recipient_id, message)
else:
pass
return "success"
return "Success"


if __name__ == "__main__":
Expand Down

0 comments on commit acf3db3

Please sign in to comment.