def webhook(request):
webhook_secret = 'YOUR_WEBHOOK_SECRET_HERE'
if request.POST.get('secret') != webhook_secret:
return HttpResponse("Invalid webhook secret", 'text/plain', 403)
if request.POST.get('event') == 'incoming_message':
content = request.POST.get('content')
from_number = request.POST.get('from_number')
phone_id = request.POST.get('phone_id')
# do something with the message, e.g. send an autoreply
return HttpResponse(json.dumps({
'messages': [
{'content': "Thanks for your message!"}
]
}), 'application/json')
评论列表
文章目录