Go SDK

Install

The Uni Go SDK provides Go Modules, which are available from the public Github repository.

Add uni-go-sdk to the project as a dependency:

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

Usage

The following example shows how to use the Uni Go SDK to quickly invoke a service.

Send an SMS


package main

import (
    "fmt"
    unisms "github.com/apistd/uni-go-sdk/sms"
)

func main() {
    // initialization
    client := unisms.NewClient("your access key id", "your access key secret") // if you use the simple auth mode, just pass in the first parameter
    client.Client.SetEndpoint("https://api.unimtx.com") // set endpoint

    // build a message
    message := unisms.BuildMessage()
    message.SetTo("your phone number")
    message.SetSignature("Unimatrix")
    message.SetTemplateId("pub_verif_basic")
    message.SetTemplateData(map[string]string {"code": "6666"}) // set custom parameters (variable SMS)

    // send the message
    res, err := client.Send(message)
    if (err != nil) {
        fmt.Println(err)
        return
    }
    fmt.Println(res)
}