Skip to content

Instantly share code, notes, and snippets.

@JudeMolloy
Last active September 28, 2017 20:43
Show Gist options
  • Save JudeMolloy/ff1bf5fa0a7eb88b7aeb15b4d7188da1 to your computer and use it in GitHub Desktop.
Save JudeMolloy/ff1bf5fa0a7eb88b7aeb15b4d7188da1 to your computer and use it in GitHub Desktop.
def get(self, request, *args, **kwargs):
if self.request.GET['hub.verify_token'] == '7221896199':
return HttpResponse(self.request.GET['hub.challenge'])
else:
return HttpResponse('Error, invalid token')
@method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs):
return generic.View.dispatch(self, request, *args, **kwargs)
# POST function to handle Facebook messages
def post(self, request, *args, **kwargs):
# Converts the text payload into a python dictionary
incoming_message = json.loads(self.request.body.decode('utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment