Создание USSD-меню с помощью Django
Я создаю веб-приложение USSD с Django и использую API https://documenter.getpostman.com/view/7705958/UyrEhaLQ#intro У меня проблема с отправкой ответа и отображением меню при наборе USSD-кода.
@csrf_exempt
def ussd(request):
if request.method == 'GET':
html = "<html><body>Nothing here baby!</body></html>"
return HttpResponse(html)
elif request.method == 'POST':
url = "https://99c9-102-176-94-213.ngrok.io/ussd"
code_id = request.POST.get("USERID")
serviceCode = request.POST.get("MSISDN")
type = request.POST.get("MSGTYPE")
session_id = request.POST.get("SESSIONID")
text = request.POST.get("USERDATA")
MSG = ""
if text == "":
MSG = "Welcome To Votedigital"
elif text == "1":
MSG = "Test Two"
payload ={
"USERID": code_id,
"MSISDN": serviceCode,
"MSGTYPE": type,
"USERDATA": text,
"SESSIONID": session_id,
"MSG": MSG,
}
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
print(code_id)
print(response.text)
return HttpResponse(response)
Когда я проверяю резюме своего сообщения, элементы пустые
{
"USERID": null,
"MSISDN": null,
"MSGTYPE": null,
"USERDATA": null,
"SESSIONID": null,
"MSG": ""
}