-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
133 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import os | ||
from os.path import join, dirname | ||
from dotenv import load_dotenv | ||
import vonage | ||
|
||
dotenv_path = join(dirname(__file__), '../.env') | ||
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') | ||
TO_NUMBER = os.getenv('TO_NUMBER') | ||
VONAGE_BRAND_NAME = os.getenv('VONAGE_BRAND_NAME') | ||
VONAGE_BRAND_NAME = os.getenv("VONAGE_BRAND_NAME") | ||
TO_NUMBER = os.getenv("TO_NUMBER") | ||
|
||
client = vonage.Client(key=VONAGE_API_KEY, secret=VONAGE_API_SECRET) | ||
from vonage import Auth, Vonage | ||
from vonage_sms import SmsMessage, SmsResponse | ||
|
||
response = client.sms.send_message({ | ||
'from': VONAGE_BRAND_NAME, | ||
'to': TO_NUMBER, | ||
'text': 'こんにちは世界', | ||
'type': 'unicode', | ||
}) | ||
client = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET)) | ||
|
||
if response["messages"][0]["status"] == "0": | ||
print("Message sent successfully.") | ||
else: | ||
print(f"Message failed with error: {response['messages'][0]['error-text']}") | ||
message = SmsMessage( | ||
to=TO_NUMBER, | ||
from_=VONAGE_BRAND_NAME, | ||
text='こんにちは世界', | ||
type='unicode', | ||
) | ||
|
||
response: SmsResponse = client.sms.send(message) | ||
print(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,25 @@ | ||
# Import dependencies | ||
import os | ||
from os.path import join, dirname | ||
from dotenv import load_dotenv | ||
import vonage | ||
|
||
# Load the environment | ||
envpath = join(dirname(__file__), '../.env') | ||
load_dotenv(envpath) | ||
dotenv_path = join(dirname(__file__), "../.env") | ||
load_dotenv(dotenv_path) | ||
|
||
# Initialise the client | ||
client = vonage.Client( | ||
key=os.getenv('VONAGE_API_KEY'), | ||
signature_secret=os.getenv('VONAGE_SIGNATURE_SECRET'), | ||
signature_method='md5' # MD5 HMAC, need to select this option in the developer dashboard | ||
) | ||
VONAGE_API_KEY = os.getenv('VONAGE_API_KEY') | ||
VONAGE_SIGNATURE_SECRET = os.getenv('VONAGE_SIGNATURE_SECRET') | ||
VONAGE_BRAND_NAME = os.getenv("VONAGE_BRAND_NAME") | ||
TO_NUMBER = os.getenv("TO_NUMBER") | ||
|
||
from vonage import Auth, Vonage | ||
from vonage_sms import SmsMessage, SmsResponse | ||
|
||
# Define variables - replace FROM_NUMBER and TO_NUMBER with actual numbers | ||
from_number = os.getenv('FROM_NUMBER') | ||
to_number = os.getenv('TO_NUMBER') | ||
text = 'A text message sent using the Vonage SMS API' | ||
client = Vonage(Auth(api_key=VONAGE_API_KEY, signature_secret=VONAGE_SIGNATURE_SECRET)) | ||
|
||
# Sending the sms | ||
response = client.sms.send_message({ | ||
"from": from_number, | ||
"to": to_number, | ||
"text": text | ||
}) | ||
message = SmsMessage( | ||
to=TO_NUMBER, | ||
from_=VONAGE_BRAND_NAME, | ||
text="A text message sent using the Vonage SMS API.", | ||
) | ||
|
||
if response["messages"][0]["status"] == "0": | ||
print("Message sent successfully.") | ||
else: | ||
print(f"Message failed with error: {response['messages'][0]['error-text']}") | ||
response: SmsResponse = client.sms.send(message) | ||
print(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
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') | ||
|
||
from vonage import Auth, Vonage | ||
|
||
client = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET)) | ||
|
||
client.sms.submit_sms_conversion( | ||
message_id='MESSAGE_ID', | ||
delivered=True, | ||
timestamp='2020-01-01T12:00:00Z', | ||
) | ||
|
||
if client.http_client.last_response.status_code == 200: | ||
print('Conversion submitted successfully.') | ||
else: | ||
print('Conversion not submitted.') |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
from os.path import join, dirname | ||
|
||
from dotenv import load_dotenv | ||
|
||
# Load the environment | ||
envpath = join(dirname(__file__), '../.env') | ||
load_dotenv(envpath) | ||
|
||
VONAGE_API_KEY = os.getenv("VONAGE_API_KEY") | ||
VONAGE_SIGNATURE_SECRET = os.getenv("VONAGE_SIGNATURE_SECRET") | ||
VONAGE_SIGNATURE_SECRET_METHOD = os.getenv("VONAGE_SIGNATURE_SECRET_METHOD") | ||
|
||
from fastapi import FastAPI, Request | ||
from vonage import Auth, Vonage | ||
|
||
client = Vonage( | ||
Auth( | ||
api_key=VONAGE_API_KEY, | ||
signature_secret=VONAGE_SIGNATURE_SECRET, | ||
signature_method=VONAGE_SIGNATURE_SECRET_METHOD, | ||
) | ||
) | ||
|
||
app = FastAPI() | ||
|
||
|
||
@app.get('/') | ||
async def verify_signed_webhook(request: Request): | ||
data = await request.json() | ||
|
||
if client.http_client.auth.check_signature(data): | ||
print('Valid signature') | ||
else: | ||
print('Invalid signature') |