Documentation
¶
Index ¶
- Constants
- func GET[RET any](c *Client, url string) (*RET, error)
- func Signature(encrypt string, timestamp string, nonce string, token string) string
- func VerifySignature(query url.Values, encrypt string, token string) error
- type AccessTokenResponse
- type Client
- func (c *Client) AccessToken() (*AccessTokenResponse, error)
- func (c *Client) AppId() string
- func (c *Client) Close() error
- func (c *Client) GetAccessToken() string
- func (c *Client) MenusCreate(accessToken string, buttons []*MenusCreateButton) (*GeneralResponse, error)
- func (c *Client) MenusDelete(accessToken string) (*GeneralResponse, error)
- func (c *Client) MenusGet(accessToken string) (*MenusGetResponse, error)
- func (c *Client) ServiceMessageSend(accessToken string, to string, content *ServiceMessageContent) (*TemplateMessageSendResponse, error)
- func (c *Client) SetAccessToken(token string, expired time.Time)
- func (c *Client) SnsAccessToken(code string) (*SnsAccessTokenResponse, error)
- func (c *Client) SnsRefreshToken(refreshToken string) (*SnsAccessTokenResponse, error)
- func (c *Client) SnsUserinfo(accessToken string, openId string) (*SnsUserinfoResponse, error)
- func (c *Client) TemplateMessageSend(accessToken string, params *TemplateMessageSendRequest) (*TemplateMessageSendResponse, error)
- func (c *Client) VerifySignature(query url.Values, encrypt string) error
- type EventNotifyRequest
- type GeneralResponse
- type IGeneralResponse
- type MenusCreateButton
- type MenusCreateSubButton
- type MenusGetResponse
- type MessageNotifyRequest
- type NotifyEncryptedRequest
- type NotifyEncryptedResponse
- type ServiceMessageContent
- type ServiceMessageMenu
- type SnsAccessTokenResponse
- type SnsUserinfoResponse
- type TemplateMessageSendRequest
- type TemplateMessageSendResponse
Constants ¶
const ServiceMessageNew serviceMessageNew = 0
Variables ¶
This section is empty.
Functions ¶
func Signature ¶
Signature 请求签名计算 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Message_encryption_and_decryption_instructions.html
Types ¶
type AccessTokenResponse ¶
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 (*Client) AccessToken ¶
func (c *Client) AccessToken() (*AccessTokenResponse, error)
AccessToken 获取AccessToken https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_access_token.html
func (*Client) GetAccessToken ¶
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) ServiceMessageSend ¶
func (c *Client) ServiceMessageSend(accessToken string, to string, content *ServiceMessageContent) (*TemplateMessageSendResponse, error)
ServiceMessageSend 发送客服消息 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Service_Center_messages.html
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) TemplateMessageSend ¶
func (c *Client) TemplateMessageSend(accessToken string, params *TemplateMessageSendRequest) (*TemplateMessageSendResponse, error)
TemplateMessageSend 发送模板消息 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html
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 ¶
func (*GeneralResponse) General ¶
func (g *GeneralResponse) General() *GeneralResponse
type IGeneralResponse ¶
type IGeneralResponse interface {
General() *GeneralResponse
}
type MenusCreateButton ¶
type MenusCreateSubButton ¶
type MenusGetResponse ¶
type MenusGetResponse struct {
IsMenuOpen int `json:"is_menu_open"`
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 SnsAccessTokenResponse ¶
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"`
}