Go SDK

Installation

The Unimatrix SDK for Golang uses Go Modules, which is available from the public Github repository.

Run the following command to add uni-go-sdk as a dependency to your project:

go get github.com/unimtx/uni-go-sdk

Usage

The following example shows how to use the Unimatrix Go SDK to interact with Unimatrix services.

Send SMS

Send a text message to a single recipient.


package main

import (
    "fmt"
    "github.com/unimtx/uni-go-sdk"
)

func main() {
    // initialization
    client := uni.NewClient("your access key id", "your access key secret") // if you use the simple auth mode, just pass in the first parameter

    // send the message
    res, err := client.Messages.Send(&uni.MessageSendParams{
        To: "your phone number",  // in E.164 format
        Signature: "your sender name",
        Content: "Your verification code is 2048.",
    })
    if (err != nil) {
        fmt.Println(err)
    } else {
        fmt.Println(res)
    }
}

Send a message using a template with variables.

client.Messages.Send(&uni.MessageSendParams{
    To: "+1650253xxxx",
    Signature: "Unimatrix",
    TemplateId: "pub_verif_en_basic2",
    TemplateData: map[string]string {"code": "2048"},
})