uni

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2021 License: MIT Imports: 14 Imported by: 1

README

Uni Go SDK

UniSMS - 高可用聚合短信服务平台官方 Go SDK.

文档

查看完整产品介绍与 API 文档请访问 UniSMS Documentation.

安装

Uni Go SDK 提供 Go Module,可从公共 Github 仓库 中获得。

在项目中添加 uni-go-sdk 作为依赖:

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

使用示例

以下示例展示如何使用 Uni Go SDK 快速调用服务。

发送短信

package main

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

func main() {
    // 初始化
    client := unisms.NewClient("your access key id", "your access key secret")

    // 创建信息
    message := unisms.BuildMessage()
    message.SetTo("your phone number")
    message.SetSignature("UniSMS")
    message.SetTemplateId("login_tmpl")
    message.SetTemplateData(map[string]string {"code": "6666"}) // 设置自定义参数 (变量短信)

    // 发送短信
    res, err := client.Send(message)
    if (err != nil) {
        fmt.Println(err)
        return
    }
    fmt.Println(res)
}

相关参考

其他语言 SDK

Documentation

Index

Constants

View Source
const DEF_ENDPOINT = "https://uni.apistd.com"
View Source
const DEF_SIGNING_ALGORITHM = "hmac-sha256"
View Source
const REQUEST_ID_HEADER_KEY = "x-uni-request-id"

Variables

This section is empty.

Functions

This section is empty.

Types

type UniClient

type UniClient struct {
	AccessKeyId      string
	AccessKeySecret  string
	Endpoint         string
	SigningAlgorithm string
}

func NewClient

func NewClient(params ...string) *UniClient

func (*UniClient) GenerateRandomString

func (c *UniClient) GenerateRandomString(n int) string

func (*UniClient) Request

func (c *UniClient) Request(action string, data map[string]interface{}) (response *UniResponse, err error)

func (*UniClient) SetEndpoint

func (c *UniClient) SetEndpoint(endpoint string)

func (*UniClient) Sign

func (c *UniClient) Sign(query url.Values) url.Values

type UniResponse

type UniResponse struct {
	Raw       *http.Response
	Status    int
	Code      string
	Message   string
	Data      map[string]interface{}
	RequestId string
}

func NewResponse

func NewResponse(res *http.Response) (*UniResponse, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL