From 6893d82b2d1ef20d7815b1e1a651c437a687f84d Mon Sep 17 00:00:00 2001 From: Tony Bedford Date: Wed, 20 May 2020 17:10:22 +0100 Subject: [PATCH] Use NEXMO_BRAND_NAME --- example.env | 3 ++- sms/send-an-sms-with-unicode.py | 10 ++++++++-- sms/send-an-sms.py | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/example.env b/example.env index f107958..5d8a9d6 100644 --- a/example.env +++ b/example.env @@ -3,6 +3,7 @@ NEXMO_API_SECRET='YOUR_API_SECRET' TO_NUMBER='EXAMPLE_TO_NUMBER' RECIPIENT_NUMBER='EXAMPLE_RECIPIENT_NUMBER' FROM_NUMBER='EXAMPLE_FROM_NUMBER' +NEXMO_BRAND_NAME='Acme Inc.' # Number Insight examples INSIGHT_NUMBER='NUMBER_FOR_INSIGHT' @@ -20,4 +21,4 @@ NEXMO_NUMBER_FEATURES='SMS,VOICE' MESSAGES_APPLICATION_ID='12a3b4cd-a1b2-1ab2-a1b2-a1234bc5d678' VOICE_CALLBACK_TYPE='tel' VOICE_CALLBACK_VALUE='447700900002' -VOICE_STATUS_URL='https://example.com/webhooks/status' \ No newline at end of file +VOICE_STATUS_URL='https://example.com/webhooks/status' diff --git a/sms/send-an-sms-with-unicode.py b/sms/send-an-sms-with-unicode.py index 037c6ab..139f1f7 100644 --- a/sms/send-an-sms-with-unicode.py +++ b/sms/send-an-sms-with-unicode.py @@ -8,14 +8,20 @@ NEXMO_API_KEY = os.getenv('NEXMO_API_KEY') NEXMO_API_SECRET = os.getenv('NEXMO_API_SECRET') TO_NUMBER = os.getenv('TO_NUMBER') +NEXMO_BRAND_NAME = os.getenv('NEXMO_BRAND_NAME') import nexmo client = nexmo.Client(key=NEXMO_API_KEY, secret=NEXMO_API_SECRET) -client.send_message({ - 'from': 'Acme Inc', +responseData = client.send_message({ + 'from': NEXMO_BRAND_NAME, 'to': TO_NUMBER, 'text': 'こんにちは世界', 'type': 'unicode', }) + +if responseData["messages"][0]["status"] == "0": + print("Message sent successfully.") +else: + print(f"Message failed with error: {responseData['messages'][0]['error-text']}") diff --git a/sms/send-an-sms.py b/sms/send-an-sms.py index be64e22..fdb54c0 100644 --- a/sms/send-an-sms.py +++ b/sms/send-an-sms.py @@ -8,6 +8,7 @@ NEXMO_API_KEY = os.getenv("NEXMO_API_KEY") NEXMO_API_SECRET = os.getenv("NEXMO_API_SECRET") TO_NUMBER = os.getenv("TO_NUMBER") +NEXMO_BRAND_NAME = os.getenv('NEXMO_BRAND_NAME') import nexmo