Go client library for interacting with Infobip's API.
go get github.com/gaart/go-infobip
To send SMS:
import "github.com/gaart/go-infobip"
username := os.Getenv("INFOBIP_USERNAME")
password := os.Getenv("INFOBIP_PASSWORD")
client, err := infobip.NewClient(username, password)
if err != nil {
fmt.Println(err.Error())
return
}
sms := infobip.SMS{
From: "sender name",
To: []string{"+12125557890"}, // list of phone numbers
Text: "message text here",
}
res, err := client.SendSMS(&sms)
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Printf("%+v\n", res)
To get SMS delivery report:
messageID := "123123123" // SMS ID to check
report, err := client.GetDeliveryReport(messageID)
if err != nil {
fmt.Println(err.Error())
}
fmt.Printf("%+v\n", report)