Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 1.19 KB

README.md

File metadata and controls

59 lines (43 loc) · 1.19 KB

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)