English | 简体中文
- Go 1.10+
go get github.com/uspeedo/uspeedo-sdk-go
Note if meet network problem, you can use go proxy to speed up the downloaded, eg: use GOPROXY environment variable
export GOPROXY=https://goproxy.io
Replay the command to retry installation.
Add the following snippet to any code.
import _ "github.com/uspeedo/uspeedo-sdk-go"
And execute this commands:
go mod init
go mod tidy
dep ensure -add github.com/uspeedo/uspeedo-sdk-go
Currently, Go SDK use PublicKey/PrivateKey
as authentication method, the key can be found from:
Here is a simple example:
package main
import (
"fmt"
"github.com/uspeedo/uspeedo-sdk-go/uspeedo"
"github.com/uspeedo/uspeedo-sdk-go/uspeedo/auth"
"github.com/uspeedo/uspeedo-sdk-go/services/asms"
)
func main() {
cfg := uspeedo.NewConfig()
// replace the public/private key by your own
credential := auth.NewCredential()
credential.PrivateKey = "my_private_key"
credential.PublicKey = "my_public_key"
asmsClient := asms.NewClient(&cfg, &credential)
req := asmsClient.NewSendBatchUSMSMessageRequest()
req.ChargeType = uspeedo.String("Dynamic")
req.TaskContent = []asms.SendBatchInfo{
{
TemplateId: "...",
SenderId: "",
Target: []asms.SendBatchTarget{
{
Phone: "130xxxx1321",
},
{
Phone: "130xxxx1321",
},
},
},
}
// send request
resp, err := asmsClient.SendBatchUSMSMessage(req)
if err != nil {
fmt.Printf("something bad happened: %s\n", err)
} else {
fmt.Printf("response of the request: %v\n", resp)
}
}