Skip to content

Commit 8152405

Browse files
committed
update sms smaples
1 parent f06c854 commit 8152405

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

messages/sms/send-sms.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
)
2323
)
2424

25-
client.messages.send(
25+
response = client.messages.send(
2626
Sms(
2727
to=TO_NUMBER,
2828
from_=VONAGE_BRAND_NAME,
2929
text='This is an SMS sent using the Vonage Messages API.',
3030
)
3131
)
32+
print(response)

sms/delivery-receipts.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import os
2+
from os.path import join, dirname
3+
4+
from dotenv import load_dotenv
5+
6+
# Load the environment
7+
envpath = join(dirname(__file__), '../.env')
8+
load_dotenv(envpath)
9+
10+
VONAGE_API_KEY = os.getenv("VONAGE_API_KEY")
11+
VONAGE_SIGNATURE_SECRET = os.getenv("VONAGE_SIGNATURE_SECRET")
12+
VONAGE_SIGNATURE_SECRET_METHOD = os.getenv("VONAGE_SIGNATURE_SECRET_METHOD")
13+
14+
from fastapi import FastAPI, Request
15+
from vonage import Auth, Vonage
16+
17+
client = Vonage(
18+
Auth(
19+
api_key=VONAGE_API_KEY,
20+
signature_secret=VONAGE_SIGNATURE_SECRET,
21+
signature_method=VONAGE_SIGNATURE_SECRET_METHOD,
22+
)
23+
)
24+
25+
app = FastAPI()
26+
27+
28+
@app.get('/delivery-receipt')
29+
async def get_delivery_receipt(request: Request):
30+
data = await request.json()
31+
32+
if client.http_client.auth.check_signature(data):
33+
print('Valid signature')
34+
else:
35+
print('Invalid signature')

0 commit comments

Comments
 (0)