Nic*_*nié 10
正如 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)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4260 次 |
| 最近记录: |