Skip to content

gaart/go-infobip

Repository files navigation

Infobip API Go client

Go Report Card GoDoc license

Go client library for interacting with Infobip's API.

Install

go get github.com/gaart/go-infobip

Usage

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)

Releases

No releases published

Packages

No packages published

Languages