Logo Lanfrica

Tech-Kenya/africastalkingsms

Domain:

digital infrastructure

Record type:

software
Creator:
Tec
Host:
Africastalking Golang SMS library ## Africastalking Golang SMS library This is a Golang library for sending SMS messages using the Africa's Talking API. It provides a simple interface to send messages, check message status, and manage contacts. ## Installation To install the library, use the following command: ```bash go get github.com ``` Sample code to send an SMS: ```go package main import ( "log" "os" africastalking "github.com" ) func main() { apiKey := os.Getenv("atApiKey") username := os.Getenv("atUserName") atShortCode := os.Getenv("atShortCode") sandbox := os.Getenv("sandboxEnv") client, err := africastalking.NewSMSClient(apiKey, username, atShortCode, sandbox) if err != nil { log.Fatal(err) } resp, err := client.SendSMS("+254712345678", "Hello from Africa's Talking!") if err != nil { log.Fatal(err) } log.Println(resp) } ``` ## To get started locally 1. Clone the repository: ```bash git clone github.com ``` 2. cd into the project directory ```bash cd africastalkingsms/demo ``` 3. Copy the `.env.example` file to `.env` and fill in your Africa's Talking credentials: ```bash cp .env.example .env cp .env.example .envrc ``` `Ensure you have Golang 1,18+ installed on your machine and you have an API key from Africa's Talking.` - Register an account: - Shortcode or Sender ID: - API Key: - See more: - Launch a simulator: ###### note that after generating a new API key, it might take upto 15 mins for it to become active optionally, save the old api key, then create a new one, but continue using the old key 4. Install the dependencies: ```bash go mod tidy ``` 5. Run the example: ```bash export $(cat .env | xargs) #then go run . ``` ## Usage see demo/api for a simple API example (remember to edit .env file with your credentials) ```bash go mod tidy #download dependencies ``` ```bash go run . #start the api server ``` POST Request ```bash curl -X POST loca

Licenses