This repository contains basic SMS sending scripts to demonstrate the Messages & SMS service of HUAWEI CLOUD (International SMS).
- Install Miniconda if not already installed: https://docs.conda.io/en/latest/miniconda.html
- Create a Conda virtual environment using Python 3.10 (
msgsms
is used as the environment name):conda create -n msgsms python=3.10 -y
- Activate the virtual environment:
conda activate msgsms
- Install Python requirements with pip:
pip install -r requirements.txt
Please check the overall usage flow in the Help Center: How to Use International SMS.
- Create SMS application - https://support.huaweicloud.com/intl/en-us/usermanual-msgsms/sms_03_0013.html
- Create SMS Template - https://support.huaweicloud.com/intl/en-us/usermanual-msgsms/sms_03_0016.html
For the examples of this repository, two templates were created:
Notification template, used in the send_notification.py
script:
Reservation confirmed at ${DATE} ${TIME} for ${NUM_3} people.
Show the following code at the reservation day: ${TXT_20}.
Verification code template, used in the send_verification_code.py
script:
${NUM_8} is your verification code on our demo app.
- Make a copy of
.env.example
named.env
, and setAPP_KEY
,APP_SECRET
,APP_ACCESS_ADDRESS
andCHANNEL_NO
. All those values are obtained from Application Management page; - Get the notification template ID and update
TEMPLATE_ID
insidesend_notification.py
script; - Get the verification code template ID and update
TEMPLATE_ID
insidesend_verification_code.py
script; - Follow one of the examples below.
python send_verification_code.py "+5511912345678" "123456"
The expected output is the following:
{'code': '000000',
'description': 'Success',
'result': [{'createTime': '2023-03-28T20:07:20Z',
'from': 'msg...',
'originTo': '+5511912345678',
'smsMsgId': '98c...939',
'status': '000000'}]}
python send_notification.py "+5511912345678" "2023/3/30" "10:30" "25" "ABCD1234"
The expected output is the following:
{'code': '000000',
'description': 'Success',
'result': [{'createTime': '2023-03-28T20:07:20Z',
'from': 'msg...',
'originTo': '+5511912345678',
'smsMsgId': '98c...939',
'status': '000000'}]}