Skip to content
Permalink
master
Switch branches/tags
Go to file
6 contributors

Users who have contributed to this file

@alphacentauri82 @adambutler @superdiana @slorello89 @maxkahan @judy2k
import os
from os.path import join, dirname
from dotenv import load_dotenv
dotenv_path = join(dirname(__file__), "../.env")
load_dotenv(dotenv_path)
VONAGE_API_KEY = os.getenv("VONAGE_API_KEY")
VONAGE_API_SECRET = os.getenv("VONAGE_API_SECRET")
VONAGE_BRAND_NAME = os.getenv("VONAGE_BRAND_NAME")
TO_NUMBER = os.getenv("TO_NUMBER")
import vonage
client = vonage.Client(key=VONAGE_API_KEY, secret=VONAGE_API_SECRET)
responseData = client.sms.send_message(
{
"from": VONAGE_BRAND_NAME,
"to": TO_NUMBER,
"text": "A text message sent using the Nexmo SMS API",
}
)
if responseData["messages"][0]["status"] == "0":
print("Message sent successfully.")
else:
print(f"Message failed with error: {responseData['messages'][0]['error-text']}")