File tree 2 files changed +37
-1
lines changed
2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 22
22
)
23
23
)
24
24
25
- client .messages .send (
25
+ response = client .messages .send (
26
26
Sms (
27
27
to = TO_NUMBER ,
28
28
from_ = VONAGE_BRAND_NAME ,
29
29
text = 'This is an SMS sent using the Vonage Messages API.' ,
30
30
)
31
31
)
32
+ print (response )
Original file line number Diff line number Diff line change
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' )
You can’t perform that action at this time.
0 commit comments