我目前正在尝试实现网络钩子这个网站 https://developer.typeform.com/webhooks/walkthroughs/。我在文档中找不到太多有关创建 Webhook 的内容。您是否有任何好的存储库或页面可供我查看,以更好地了解如何为 Typeform 构建 Webhook?
正如 Daniel 在评论中指出的那样,webhook 接收器只是 Django 应用程序中的另一个端点,用于接受 POST 请求并处理 JSON 输入。
我试图整理一个例子,希望有帮助。
import json
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
@csrf_exempt
@require_POST
def webhook_endpoint(request):
jsondata = request.body
data = json.loads(jsondata)
for answer in data['form_response']['answers']: # go through all the answers
type = answer['type']
print(f'answer: {answer[type]}') # print value of answers
return HttpResponse(status=200)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)