-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsend-sms.py
More file actions
25 lines (22 loc) · 908 Bytes
/
Copy pathsend-sms.py
File metadata and controls
25 lines (22 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from ringcentral import SDK
import os
from dotenv import Dotenv
dotenv = Dotenv(os.path.join(os.path.dirname(__file__), ".env"))
os.environ.update(dotenv)
rcsdk = SDK( os.getenv("RINGCENTRAL_CLIENT_ID"),
os.getenv("RINGCENTRAL_CLIENT_SECRET"),
os.getenv("RINGCENTRAL_SERVER_URL") )
platform = rcsdk.platform()
platform.login( os.getenv("RINGCENTRAL_USERNAME"),
os.getenv("RINGCENTRAL_EXTENSION"),
os.getenv("RINGCENTRAL_PASSWORD") )
params = {
'from': {'phoneNumber': os.getenv("RINGCENTRAL_USERNAME")},
'to': [{'phoneNumber': os.getenv("RECIPIENT_PHONE_NUMBER")}],
'text': 'This is a test message from Python'
}
try:
response = platform.post('/account/~/extension/~/sms', params)
print("Message sent. Delivery status: " + str(response.json().messageStatus))
except Exception as e:
print(e)