wxofficial

package module
v0.0.0-...-45be4db Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: BSD-3-Clause Imports: 13 Imported by: 0

README

微信公众号简易框架

Intro

安装

go get github.com/star-os/wxofficial

使用

Documentation

Index

Constants

View Source
const (
	UrlSuffixAccesstoken = UrlPrefix + "token?grant_type=%s&appid=%s&secret=%s"
	GrantTypeAccessToken = "client_credential"
)
View Source
const (
	MenuCreateUrl = UrlPrefix + `menu/create?access_token=%s`
	MenuGetUrl    = UrlPrefix + `get_current_selfmenu_info?access_token=%s`
	MenuDeleteUrl = UrlPrefix + `menu/delete?access_token=%s`
	// MenuGetConfig = `https://api.weixin.qq.com/cgi-bin/menu/get?access_token=%s`
	ConditionalCreateUrl   = UrlPrefix + `menu/addconditional?access_token=%s`
	ConditionalDeleteUrl   = UrlPrefix + `delconditional?access_token=%s`
	ConditionalTryMatchUrl = UrlPrefix + `menu/trymatch?access_token=%s`
)
View Source
const (
	UrlPrefix = "https://api.weixin.qq.com/cgi-bin/"
)

Variables

This section is empty.

Functions

func AddButton

func AddButton(b ...button.Button)

AddButton 为菜单添加按钮

func Encoding

func Encoding(params ...string) string

Encoding 用于sha1加密

Types

type Config

type Config struct {
	Token          string
	EncodingAESKey string
	AppId          string
	AppSecret      string
}

func NewConfig

func NewConfig(token, encodingAESKey, appId, appSecret string) *Config

type Context

type Context struct {
	Config

	// 控制部分
	accesstoken.AccessToken
	UpdateChan chan int
	// contains filtered or unexported fields
}

Context 中控部分

func NewContext

func NewContext(token, encodingAESKey, appId, appSecret string) *Context

NewContext 初始化一个Context,并启动AccessToken的中控goroutine

func (*Context) CheckSignature

func (c *Context) CheckSignature(signature, nonce, timestamp string) bool

CheckSignature 用于校验signature,接入微信平台

func (*Context) DelConditional

func (c *Context) DelConditional() error

DelConditional 删除个性化菜单

func (*Context) DeleteMenu

func (c *Context) DeleteMenu() error

DeleteMenu 删除接口

func (*Context) GetAccessToken

func (c *Context) GetAccessToken() string

GetAccessToken 获取AccessToken

func (*Context) QueryMenu

func (c *Context) QueryMenu() ([]byte, error)

QueryMenu 查询接口

func (*Context) SetMenu

func (c *Context) SetMenu() error

SetMenu 用于设置微信公众号的菜单(上传到微信公众号)

func (*Context) SetMenuByJson

func (c *Context) SetMenuByJson(j []byte) error

SetMenuByJson 直接通过JSON设置菜单

func (*Context) UpdateAccessToken

func (c *Context) UpdateAccessToken() error

UpdateAccessToken 更新AccessToken

type Menu struct {
	B                 []button.Button `json:"button,omitempty"`
	*button.MatchRule `json:"matchrule,omitempty"`
}

Menu 包含了按钮以及个性化菜单的数据,用于Marshall成JSON进行发送

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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