Alidayu

package module
v0.0.0-...-772989e Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2018 License: MIT Imports: 16 Imported by: 0

README

Alidayu

Alidayu communication Go library.

The current version supports the sms function.

API documents:

  1. Signature method
  2. Sms sending

**Example Code: **

	smsConfig := SMSConfig{
		APPKey:       "",
		APPSecret:    "",
		FreeSignName: "阿里大于",
		Param: map[string]string{
			"code":    "1234",
			"product": "alidayu",
		},
		PhoneNumber:  "13000000000",
		TemplateCode: "SMS_585014",
	}
	sms, err := NewSMS(smsConfig)
	if err != nil {
		t.Error(err)
	}

	statusCode, err := sms.SendSMS()
	if err != nil {
		t.Errorf("status code is %d, error is %s", statusCode, err.Error())
	}
}

Similar API: Aliyuncs API

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoRequest

func DoRequest(method, url string, body []byte) (int, error)

DoRequest sends a http request

Types

type SMS

type SMS struct {
	URL       string
	APPKey    string
	APPSecret string
	SMSParam  SMSParam
}

func NewSMS

func NewSMS(config SMSConfig) (*SMS, error)

NewSMS creates a sms handler

func (*SMS) GetURLQuery

func (sms *SMS) GetURLQuery() (string, error)

GetURLQuery generates the body that the http request needs

func (*SMS) SendSMS

func (sms *SMS) SendSMS() (int, error)

SendSMS sends sms request

type SMSConfig

type SMSConfig struct {
	APPKey    string
	APPSecret string

	// The sms signature. The value must be as same
	// as the accessible signature in alidayu management
	// center. The sample: 阿里大于. Required field
	FreeSignName string

	// The sms template parameters. key-value format.
	// The key must be as same as ones in the template.
	// The sample: {"code":"1234","product":"alidayu"}
	// Optional field.
	Param map[string]string

	// Phone number. The samle: 13000000000.
	// Required field.
	PhoneNumber string

	// Sms template ID. The value must be as same as
	// the accessible signature in alidayu management
	// center. The sample: SMS_585014
	TemplateCode string
}

type SMSParam

type SMSParam struct {
	Extend         string            `json:"extend"`
	Type           string            `json:"sms_type"`
	FreeSignName   string            `json:"sms_free_sign_name"`
	Param          map[string]string `json:"sms_param"`
	ReceiverNumber string            `json:"rec_num"`
	TemplateCode   string            `json:"sms_template_code"`
	Method         string            `json:"method"`
	APPKey         string            `json:"app_key"`
	TargetAPPKey   string            `json:"target_app_key"`
	SignMethod     string            `json:"sign_method"`
	Sign           string            `json:"sign"`
	Session        string            `json:"session"`
	TimeStamp      string            `json:"timestamp"`
	Format         string            `json:"format"`
	V              string            `json:"v"`
	PartnerID      string            `json:"partner_id"`
	Simplify       bool              `json:"simplify"`
}

Jump to

Keyboard shortcuts

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