· 6 years ago · Sep 07, 2019, 03:00 AM
1import africastalking
2
3
4username = "sandbox" # use 'sandbox' for development in the test environment
5# use your sandbox app API key for development in the test environment
6api_key = "f873c8ed57eba5f24617beed4ea843449e2f48a12f4f0bece742d6faae1203a2"
7africastalking.initialize(username, api_key)
8
9
10# # Use the service synchronously
11# response = sms.send("Hello Message!", ["+2547xxxxxx"])
12# print(response)
13
14# Or use it asynchronously
15def on_finish(error, response):
16 if error is not None:
17 raise error
18 print(response)
19
20numbers = ['+254799935239']
21def send_sms(message, numbers):
22 sms = africastalking.SMS
23 sms.send(message, numbers, callback=on_finish)
24
25send_sms('Heello there am novak', numbers)