Skip to content

Instantly share code, notes, and snippets.

@kamauvick
Forked from kelvinndmo/sendtext.py
Created January 27, 2020 15:30
Show Gist options
  • Save kamauvick/a139886ffa6aa363a6fdcc67f972ccaf to your computer and use it in GitHub Desktop.
Save kamauvick/a139886ffa6aa363a6fdcc67f972ccaf to your computer and use it in GitHub Desktop.
import africastalking
username = "africa username" # use 'sandbox' for development in the test environment
# use your sandbox app API key for development in the test environment
api_key = "africa's talking api key"
africastalking.initialize(username, api_key)
# # Use the service synchronously
# response = sms.send("Hello Message!", ["+2547xxxxxx"])
# print(response)
# Or use it asynchronously
def on_finish(error, response):
if error is not None:
raise error
# write to the logs
print(response)
numbers = []
def send_sms(message, numbers):
sms = africastalking.SMS
sms.send(message, numbers, callback=on_finish)
message = "Your message hoes here"
send_sms(message, numbers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment