Provides convenient access to the Africa's Talking API from esp8266 module written in C++.
Download the zip package from here.
Once you get the library, just 3 steps are required before you can use it:
- Extract the archive.
- Place the library folder in Arduino/libraries/.
- Restart the Arduino IDE.
In you Arduino IDE got to Sketch > Include Library > Add .ZIP Library and browse to find your .zip archive. Alternatively, in the Arduino library manager search for AfricasTalking library
The library needs to be instantiated using your username and API key, which you can get from the dashboard.
You can use this library for either production or sandbox apps. For sandbox, the app username is ALWAYS sandbox.
In your .ino file:
#include <AfricasTalking.h>
static const char *apiKey = "YOUR_API_KEY";
static const char *username = "YOUR_USERNAME";
AfricasTalking *AT;
AT = new AfricasTalking(apiKey, username); String appData = AT->applicationData(); String recipients[] = { "{ \"phoneNumber\":\"+254XXXXXXXXX\",\"currencyCode\":\"KES\",\"amount\":\"5\" }" };
bool success = AT->airtime(recipients);recipients: string array with recipient infoREQUIREDphoneNumber: phone number that will be topped upREQUIREDcurrencyCode: currency codeREQUIREDamount: value of airtime to send
bool success = AT->sms(toNumber, fromNumber, message);toNumber: message recipient phone number, comma seperated for bulk sendREQUIREDfromNumber: Africa's Talking provide short codeREQUIREDmessage: message to senderREQUIRED
bool success = AT->voice(fromNumber, toNumber);toNumber: call destination phone numberREQUIREDfromNumber: Africa's Talking provide phone numberREQUIRED
Note: Implementing
Bug reports and pull requests are welcome on GitHub at https://github.com/ochiengotieno304/africastalking-esp8266/issues.
The library is available as open source under the terms of the MIT License.