- bulksmszw api for sending affordable text messages
- make sure git is installed on your system or download repo as zip
- In cmd or terminal do
$ git clone https://github.com/DonnC/BulkSmsZW-Api.git
$ cd BulkSmsZW-Api
$ python setup.py install
- or directly with pip,
python3.x
$ pip install --upgrade git+git:https://github.com/DonnC/BulkSmsZW-Api.git
- register an account on bulksms website
- if already have an account, login on bulksms web portal
- Got to "My Account", then Click on "User Configuration", to obtain "Webservices token".
- test file test_api.py
- recipients is passed as a list of bulksms valid format
2637xxxxxxxx
, list can also contain groups#devteam
and can be mixed
api = Client(<username>, <token>)
respond = api.send("hello guys", ['2637xxxxxxxx', '#devteam', '#students'])
- Example script
from BulkSmsApi.Client import Client
bulksms = Client(<username>, <web-token>)
response = bulksms.send(body="bulk sms ZW api testing", recipients=['2637xxxxxxxx', '2637yyyyyyyy'])
print(response)
credits
flag by default is set toFalse
- to receive the number of credits on your web portal, set the
credit
flag toTrue
api = Client(<username>, <token>)
credits_response = api.send(body="hello world", recipients=['2637xxxxxxxx'], credits=True)
print(credits_response)
- You can wrap your code in a
try - except
to catch unsuccessful and bulksms error messages as normal python exceptions
# this wil throw an exception because of the wrong / not valid username
bulksms = Client(username=<wrong-username>, token=<web-token>)
try:
response = bulksms.send(body="bulk sms ZW api testing", recipients=['2637xxxxxxxx', '2637yyyyyyyy'])
print(response)
except Exception as exc:
print("Encountered an Error: %s" %exc)
- responses are in default JSON format used by BulkSMSZW service
- Big shoutout to the BulkSMS ZW team
- Original bulksms python api script
- All credits to the Bulk SMS ZW Team
- api docs HTTP API INTEGRATION DOC
- Schedule messages
- Validate phone numbers