我需要得到支持的国家名单,非洲说话的api。

问题描述 投票:0回答:1

其实我想在我的USSD应用上使用Africa's talking api,我来自孟加拉国,我很困惑它是否支持孟加拉国。我来自孟加拉国,我对它是否支持孟加拉国感到困惑。孟加拉国主要有四个服务提供商,即gameenphone,robi,banglalink,airtel。我想把其中一个运营商的USSD发送到我的应用程序中。

这里是python代码。

from flask import Flask, request
import africastalking
import os

app = Flask(__name__)
username = "sandbox"
api_key = "*384*89376#"
africastalking.initialize(username, api_key)
sms = africastalking.SMS

@app.route('/', methods=['POST', 'GET'])
def ussd_callback():
    global response
    session_id = request.values.get("sessionId", None)
    service_code = request.values.get("serviceCode", None)
    phone_number = request.values.get("phoneNumber", None)
    text = request.values.get("text", "default")
    sms_phone_number = []
    sms_phone_number.append(phone_number)

    #ussd logic
    if text == "":
        #main menu
        response = "CON What would you like to do?\n"
        response += "1. Check account details\n"
        response += "2. Check phone number\n"
        response += "3. Send me a cool message"
    elif text == "1":
        #sub menu 1
        response = "CON What would you like to check on your account?\n"
        response += "1. Account number"
        response += "2. Account balance"
    elif text == "2":
        #sub menu 1
        response = "END Your phone number is {}".format(phone_number)
    elif text == "3":
        try:
            #sending the sms
            sms_response = sms.send("Thank you for going through this tutorial", 
sms_phone_number)
            print(sms_response)
        except Exception as e:
            #show us what went wrong
            print(f"Houston, we have a problem: {e}")
    elif text == "1*1":
        #ussd menus are split using *
        account_number = "1243324376742"
        response = "END Your account number is {}".format(account_number)
    elif text == "1*2":
        account_balance = "100,000"
        response = "END Your account balance is USD {}".format(account_balance)
    else:
        response = "END Invalid input. Try again."

    return response

if __name__ == "__main__":
    app.run()
api ussd
1个回答
0
投票

非洲的Talking USSD服务在以下国家。

肯尼亚,乌干达,坦桑尼亚,卢旺达,尼日利亚科特迪瓦,马拉维,赞比亚,南非。

希望对大家有所帮助。如果你还有什么问题,可以联系我。

© www.soinside.com 2019 - 2024. All rights reserved.