wxoa

package
v0.0.0-...-61d9652 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ServiceMessageNew serviceMessageNew = 0

Variables

This section is empty.

Functions

func GET

func GET[RET any](c *Client, url string) (*RET, error)

Types

type AccessTokenResponse

type AccessTokenResponse struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
}

type Client

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

Client 微信公众号 API client https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html

func NewClient

func NewClient(hc *wsa.HttpClient, appId string, secret string) *Client

func (*Client) AppId

func (c *Client) AppId() string

func (*Client) Close

func (c *Client) Close() error

func (*Client) GetAccessToken

func (c *Client) GetAccessToken() string

func (*Client) MenusCreate

func (c *Client) MenusCreate(accessToken string, buttons []*MenusCreateButton) (*GeneralResponse, error)

MenusCreate 创建自定义菜单接口 https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Creating_Custom-Defined_Menu.html

func (*Client) MenusDelete

func (c *Client) MenusDelete(accessToken string) (*GeneralResponse, error)

MenusDelete 删除自定义菜单接口 https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Deleting_Custom-Defined_Menu.html

func (*Client) MenusGet

func (c *Client) MenusGet(accessToken string) (*MenusGetResponse, error)

MenusGet 查询自定义菜单接口 https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Querying_Custom_Menus.html

func (*Client) SetAccessToken

func (c *Client) SetAccessToken(token string, expired time.Time)

func (*Client) SnsAccessToken

func (c *Client) SnsAccessToken(code string) (*SnsAccessTokenResponse, error)

SnsAccessToken 通过code换取网页授权access_token https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html

func (*Client) SnsRefreshToken

func (c *Client) SnsRefreshToken(refreshToken string) (*SnsAccessTokenResponse, error)

SnsRefreshToken 刷新access_token https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html

func (*Client) SnsUserinfo

func (c *Client) SnsUserinfo(accessToken string, openId string) (*SnsUserinfoResponse, error)

SnsUserinfo 拉取用户信息 https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html

func (*Client) VerifySignature

func (c *Client) VerifySignature(query url.Values, encrypt string) error

VerifySignature 回调验签

type EventNotifyRequest

type EventNotifyRequest struct {
	ToUserName   string `json:"ToUserName" xml:"ToUserName"`
	FromUserName string `json:"FromUserName" xml:"FromUserName"`
	CreateTime   int64  `json:"CreateTime" xml:"CreateTime"`
	MsgType      string `json:"MsgType" xml:"MsgType"`
	Event        string `json:"Event" xml:"Event"`
	EventKey     string `json:"EventKey" xml:"EventKey"`
	Ticket       string `json:"Ticket" xml:"Ticket"`
}

EventNotifyRequest 事件推送 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_event_pushes.html

type GeneralResponse

type GeneralResponse struct {
	Errcode int32  `json:"errcode"`
	Errmsg  string `json:"errmsg"`
}

func (*GeneralResponse) General

func (g *GeneralResponse) General() *GeneralResponse

type IGeneralResponse

type IGeneralResponse interface {
	General() *GeneralResponse
}
type MenusCreateButton struct {
	Name      string                  `json:"name"`
	Type      string                  `json:"type,omitempty"`
	Key       string                  `json:"key,omitempty"`
	SubButton []*MenusCreateSubButton `json:"sub_button,omitempty"`
	MediaId   string                  `json:"media_id,omitempty"`
	ArticleId string                  `json:"article_id,omitempty"`
}
type MenusCreateSubButton struct {
	Type      string                  `json:"type"`
	Name      string                  `json:"name"`
	Key       string                  `json:"key,omitempty"`
	Url       string                  `json:"url,omitempty"`
	Appid     string                  `json:"appid,omitempty"`
	Pagepath  string                  `json:"pagepath,omitempty"`
	SubButton []*MenusCreateSubButton `json:"sub_button"`
}
type MenusGetResponse struct {
	IsMenuOpen   int `json:"is_menu_open"`
	SelfmenuInfo struct {
		Button []*struct {
			Name      string `json:"name"`
			SubButton struct {
				List []*struct {
					Type     string `json:"type"`
					Name     string `json:"name"`
					Url      string `json:"url,omitempty"`
					Value    string `json:"value,omitempty"`
					NewsInfo *struct {
						List []*struct {
							Title      string `json:"title"`
							Author     string `json:"author"`
							Digest     string `json:"digest"`
							ShowCover  int    `json:"show_cover"`
							CoverUrl   string `json:"cover_url"`
							ContentUrl string `json:"content_url"`
							SourceUrl  string `json:"source_url"`
						} `json:"list"`
					} `json:"news_info,omitempty"`
				} `json:"list"`
			} `json:"sub_button,omitempty"`
			Type  string `json:"type,omitempty"`
			Value string `json:"value,omitempty"`
		} `json:"button"`
	} `json:"selfmenu_info"`
}

type MessageNotifyRequest

type MessageNotifyRequest struct {
	ToUserName   string `json:"ToUserName" xml:"ToUserName"`
	FromUserName string `json:"FromUserName" xml:"FromUserName"`
	CreateTime   int64  `json:"CreateTime" xml:"CreateTime"`
	MsgType      string `json:"MsgType" xml:"MsgType"`
	MsgId        int64  `json:"MsgId" xml:"MsgId"`
	MsgDataId    string `json:"MsgDataId" xml:"MsgDataId"`
	Idx          string `json:"Idx" xml:"Idx"`
	Content      string `json:"Content" xml:"Content"`
	MediaId      string `json:"MediaId" xml:"MediaId"`
	MediaId16K   string `json:"MediaId16K" xml:"MediaId16K"`
}

MessageNotifyRequest 普通消息 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_standard_messages.html

type NotifyEncryptedRequest

type NotifyEncryptedRequest struct {
	ToUserName string `json:"ToUserName" xml:"ToUserName"`
	Encrypt    string `json:"Encrypt" xml:"Encrypt"`
}

NotifyEncryptedRequest 加解消息推送结构 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Message_encryption_and_decryption_instructions.html

type NotifyEncryptedResponse

type NotifyEncryptedResponse struct {
	Encrypt      string `json:"Encrypt" xml:"Encrypt"`
	MsgSignature string `json:"MsgSignature" xml:"MsgSignature"`
	TimeStamp    string `json:"TimeStamp" xml:"TimeStamp"`
	Nonce        string `json:"Nonce" xml:"Nonce"`
}

NotifyEncryptedResponse 加解消息推送回包 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Message_encryption_and_decryption_instructions.html

type ServiceMessageContent

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

type ServiceMessageMenu

type ServiceMessageMenu struct {
	Id      string `json:"id"`
	Content string `json:"content"`
}

type SnsAccessTokenResponse

type SnsAccessTokenResponse struct {
	AccessToken    string `json:"access_token"`
	ExpiresIn      int64  `json:"expires_in"`
	RefreshToken   string `json:"refresh_token"`
	Openid         string `json:"openid"`
	Scope          string `json:"scope"`
	IsSnapshotuser int8   `json:"is_snapshotuser"`
	Unionid        string `json:"unionid"`
}

type SnsUserinfoResponse

type SnsUserinfoResponse struct {
	Openid     string   `json:"openid"`
	Nickname   string   `json:"nickname"`
	Sex        int      `json:"sex"`
	Province   string   `json:"province"`
	City       string   `json:"city"`
	Country    string   `json:"country"`
	Headimgurl string   `json:"headimgurl"`
	Privilege  []string `json:"privilege"`
	Unionid    string   `json:"unionid"`
}

type TemplateMessageSendRequest

type TemplateMessageSendRequest struct {
	Touser      string           `json:"touser"`
	TemplateId  string           `json:"template_id"`
	Url         string           `json:"url,omitempty"`
	Miniprogram *miniprogramGoto `json:"miniprogram,omitempty"`
	ClientMsgId string           `json:"client_msg_id,omitempty"`
	Data        map[string]any   `json:"data"`
}

func NewTemplateMessageSendRequest

func NewTemplateMessageSendRequest(to string, templateId string, clientMsgId string) *TemplateMessageSendRequest

func (*TemplateMessageSendRequest) SetData

func (r *TemplateMessageSendRequest) SetData(key string, value string)

func (*TemplateMessageSendRequest) SetMiniprogram

func (r *TemplateMessageSendRequest) SetMiniprogram(appId string, path string)

type TemplateMessageSendResponse

type TemplateMessageSendResponse struct {
	GeneralResponse
	MsgId int32 `json:"msgid"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳