Logo Lanfrica

aksalj/africastalking-java

Domaine:

digital infrastructure

Type de record:

software
Créateur:
aks
Hôte:
Africa's Talking Java SDK # Africa's Talking Java SDK > The SDK provides convenient access to the Africa's Talking API from applications written in Java. > > > **Android Users**: > Remember your API key has to be kept secret; hard-coding it into an apk you publish is a security risk. So on Android, use the Android SDK instead. ## Documentation Take a look at the API docs here. ## Install You can depend on the .jar through Maven (from `dl.bintray.com`): ```xml com.africastalking core 3.3.3 ``` or sbt: ``` resolvers += "africastalking maven repository" at "dl.bintray.com" // Get all services libraryDependencies += "com.africastalking" % "core" % "3.3.3" ``` or Gradle: ```groovy repositories { maven { url "dl.bintray.com" } } dependencies{ // Get all services compile 'com.africastalking:core:3.3.3' } ``` ## Usage The SDK needs to be initialized with your app username and API key, which you get from the dashboard. > You can use this SDK for either production or sandbox apps. For sandbox, the app username is **ALWAYS** `sandbox` ```java // Initialize String username = "YOUR_USERNAME"; // use 'sandbox' for development in the test environment String apiKey = "YOUR_API_KEY"; // use your sandbox app API key for development in the test environment AfricasTalking.initialize(username, apiKey); // Initialize a service e.g. SMS SmsService sms = AfricasTalking.getService(AfricasTalking.SERVICE_SMS); // Use the service List response = sms.send("Hello Message!", new String[] {"+2547xxxxxx"}); ``` See example for more usage examples. ## Initialization The following static methods are available on the `AfricasTalking` class to initialize the library: - `initialize(string username, String apiKey)`: Initialize the library. - `setLogger(Logger)`: Set logging object. - `getService(Service.class | AfricasTalking.SERVICE_*)`: Get an instance to a given service by name or by class: - Account: `Africas …