yunpian

package module
v0.0.0-...-4441722 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 13 Imported by: 0

README

Build Status

YunPian

云片网Go SDK,暂时只实现了短信发送相关接口

Installation

go get -u github.com/gotoxu/yunpian

Example usages

package main

import (
	"testing"

	"github.com/gotoxu/assert"
)

func main() {
	sms := NewClient(DefaultConfig().WithAPIKey("you api key").WithUseSSL(true)).SMS()
	input := &SingleSendRequest{
		Mobile: "13800138000",
		Text:   "您的验证码为332211,请不要告诉其他人哦",
	}

	resp, err := sms.SingleSend(input)
	if err != nil {
		panic(err)
	}

	fmt.Printf("短信发送是否成功: %t\n", resp.IsSuccess())
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchSendRequest

type BatchSendRequest struct {
	Mobile      string `url:"mobile,omitempty"`
	Text        string `url:"text,omitempty"`
	Extend      string `url:"extend,omitempty"`
	CallbackURL string `url:"callback_url,omitempty"`
}

BatchSendRequest 批量发送请求参数

func (*BatchSendRequest) Verify

func (req *BatchSendRequest) Verify() error

Verify 用于检查请求参数的正确性

type BatchSendResponse

type BatchSendResponse struct {
	TotalCount int                  `json:"total_count"`
	TotalFee   string               `json:"total_fee"`
	Unit       string               `json:"unit"`
	Data       []SingleSendResponse `json:"data"`
}

BatchSendResponse 批量发送响应结构

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client 提供云片API调用客户端

func NewClient

func NewClient(config *Config) *Client

NewClient 创建一个新的云片客户端

func (*Client) SMS

func (c *Client) SMS() *SMS

SMS 返回一个新的短信客户端

type Config

type Config struct {
	UseSSL     *bool
	HTTPClient *http.Client
	APIKey     *string
	Context    context.Context
	// contains filtered or unexported fields
}

Config 是云片sdk的相关配置项

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig 返回默认的sdk配置

func (*Config) MergeIn

func (c *Config) MergeIn(cfgs ...*Config)

MergeIn 合并多个配置

func (*Config) WithAPIKey

func (c *Config) WithAPIKey(key string) *Config

WithAPIKey 设置sdk的API key

func (*Config) WithHTTPClient

func (c *Config) WithHTTPClient(client *http.Client) *Config

WithHTTPClient 设置发送请求的Client

func (*Config) WithUseSSL

func (c *Config) WithUseSSL(use bool) *Config

WithUseSSL 设置调用API时是否使用HTTPS

type MultiSendRequest

type MultiSendRequest struct {
	Mobile      string `url:"mobile,omitempty"`
	Text        string `url:"text,omitempty"`
	Extend      string `url:"extend,omitempty"`
	CallbackURL string `url:"callback_url,omitempty"`
}

MultiSendRequest 批量个性化发送请求参数

func (*MultiSendRequest) Verify

func (req *MultiSendRequest) Verify() error

Verify 用于检查请求参数的有效性

type MultiSendResponse

type MultiSendResponse struct {
	TotalCount int                  `json:"total_count"`
	TotalFee   string               `json:"total_fee"`
	Unit       string               `json:"unit"`
	Data       []SingleSendResponse `json:"data"`
}

MultiSendResponse 批量个性化发送响应

type RegCompleteRequest

type RegCompleteRequest struct {
	Mobile string
	Time   time.Time
}

RegCompleteRequest 注册成功上报的参数

type RegCompleteResponse

type RegCompleteResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

RegCompleteResponse 注册成功上报的响应

func (*RegCompleteResponse) IsSuccess

func (resp *RegCompleteResponse) IsSuccess() bool

IsSuccess 用于验证短信发送是否成功

type SMS

type SMS struct {
	*Client
}

SMS 是短信发送客户端

func (*SMS) BatchSend

func (sms *SMS) BatchSend(input *BatchSendRequest) (*BatchSendResponse, error)

BatchSend 批量发送接口

func (*SMS) MultiSend

func (sms *SMS) MultiSend(input *MultiSendRequest) (*MultiSendResponse, error)

MultiSend 批量个性化发送接口

func (*SMS) RegComplete

func (sms *SMS) RegComplete(input *RegCompleteRequest) (*RegCompleteResponse, error)

RegComplete 注册成功上报

func (*SMS) SingleSend

func (sms *SMS) SingleSend(input *SingleSendRequest) (*SingleSendResponse, error)

SingleSend 发送单条短信

func (*SMS) TPLBatchSend

func (sms *SMS) TPLBatchSend(input *TPLBatchSendRequest) (*BatchSendResponse, error)

TPLBatchSend 指定模板群发

func (*SMS) TPLSingleSend

func (sms *SMS) TPLSingleSend(input *TPLSingleSendRequest) (*SingleSendResponse, error)

TPLSingleSend 指定模板单发接口

type SingleSendRequest

type SingleSendRequest struct {
	Mobile      string `url:"mobile,omitempty"`
	Text        string `url:"text,omitempty"`
	Extend      string `url:"extend,omitempty"`
	UID         string `url:"uid,omitempty"`
	CallbackURL string `url:"callback_url,omitempty"`
	Register    bool   `url:"register,omitempty"`
}

SingleSendRequest 单条短信发送请求

func (*SingleSendRequest) Verify

func (r *SingleSendRequest) Verify() error

Verify 用于验证请求参数的正确性

type SingleSendResponse

type SingleSendResponse struct {
	Code    int     `json:"code"`
	Message string  `json:"message"`
	Count   int     `json:"count"`
	Fee     float64 `json:"fee"`
	Unit    string  `json:"unit"`
	Mobile  string  `json:"mobile"`
	SID     int64   `json:"sid"`
}

SingleSendResponse 单条短信发送响应

func (*SingleSendResponse) IsSuccess

func (resp *SingleSendResponse) IsSuccess() bool

IsSuccess 用于验证短信发送是否成功

type TPLBatchSendRequest

type TPLBatchSendRequest struct {
	Mobile   string
	TPLID    int64
	TPLValue map[string]string
	Extend   string
	UID      string
}

TPLBatchSendRequest 指定模板群发请求参数

type TPLSingleSendRequest

type TPLSingleSendRequest struct {
	Mobile   string
	TPLID    int64
	TPLValue map[string]string
	Extend   string
	UID      string
}

TPLSingleSendRequest 指定模板单发请求参数

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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