public

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Success = 0

	HostDefault = "https://api.weixin.qq.com"
)

Variables

This section is empty.

Functions

func JsSDKUsePermissionSign added in v1.1.5

func JsSDKUsePermissionSign(jsapiTicket, nonceStr, url string, timestamp int) (sign string)

JsSDKUsePermissionSign 获取JS-SDK使用权限签名 文档介绍:https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#62

Types

type AccessToken added in v1.1.2

type AccessToken struct {
	AccessToken string `json:"access_token,omitempty"` // 获取到的凭证
	ExpiresIn   int    `json:"expires_in,omitempty"`   // 凭证有效时间,单位:秒。目前是7200秒之内的值。
	Errcode     int    `json:"errcode,omitempty"`      // 错误码
	Errmsg      string `json:"errmsg,omitempty"`       // 错误信息
}

type ErrorCode

type ErrorCode struct {
	Errcode int    `json:"errcode,omitempty"` // 错误码
	Errmsg  string `json:"errmsg,omitempty"`  // 错误信息
}

type FansData

type FansData struct {
	Openid []string `json:"openid"`
}

type QRCodeRsp

type QRCodeRsp struct {
	Errcode       int    `json:"errcode,omitempty"`
	Errmsg        string `json:"errmsg,omitempty"`
	Ticket        string `json:"ticket"`
	ExpireSeconds int    `json:"expire_seconds,omitempty"`
	Url           string `json:"url"`
}

type SDK

type SDK struct {
	DebugSwitch wechat.DebugSwitch
	Appid       string
	Secret      string
	Host        string

	RefreshInternal time.Duration
	// contains filtered or unexported fields
}

func New

func New(appid, secret string, autoManageToken bool) (p *SDK, err error)

New 初始化微信公众号 SDK Appid:Appid Secret:appSecret autoManageToken:是否自动获取并自动维护刷新 AccessToken

func (*SDK) DoRequestGet added in v1.1.2

func (s *SDK) DoRequestGet(c context.Context, path string, ptr any) (res *http.Response, err error)

func (*SDK) GetApiTicket added in v1.1.5

func (s *SDK) GetApiTicket(c context.Context) (at *TicketRsp, err error)

GetApiTicket 获取卡券 api_ticket 注意:errcode = 0 为成功 文档:https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#54

func (*SDK) GetJsApiTicket added in v1.1.5

func (s *SDK) GetJsApiTicket(c context.Context) (jt *TicketRsp, err error)

GetJsApiTicket 获取 jsapi_ticket 注意:errcode = 0 为成功 文档:https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#62

func (*SDK) GetPublicAccessToken added in v1.1.2

func (s *SDK) GetPublicAccessToken() (at string)

GetPublicAccessToken get public access token string

func (*SDK) QRCodeCreate

func (s *SDK) QRCodeCreate(c context.Context, body bm.BodyMap) (qr *QRCodeRsp, err error)

QRCodeCreate 生成带参数的二维码 注意:errcode = 0 为成功 注意:expire_seconds 字段不传,代表永久二维码。 文档:https://developers.weixin.qq.com/doc/offiaccount/Account_Management/Generating_a_Parametric_QR_Code.html

func (*SDK) SetHttpClient added in v1.1.6

func (s *SDK) SetHttpClient(client *xhttp.Client)

SetHttpClient 设置自定义的xhttp.Client

func (*SDK) SetLogger added in v1.1.6

func (s *SDK) SetLogger(logger xlog.XLogger)

func (*SDK) SetPublicAccessToken added in v1.1.2

func (s *SDK) SetPublicAccessToken(accessToken string)

SetPublicAccessToken set public access token string

func (*SDK) SetPublicAccessTokenCallback added in v1.1.2

func (s *SDK) SetPublicAccessTokenCallback(fn func(appid, accessToken string, expireIn int, err error))

SetPublicAccessTokenCallback set public access token callback listener

func (*SDK) ShortKeyFetch

func (s *SDK) ShortKeyFetch(c context.Context, shortKey string) (skf *ShortKeyFetchRsp, err error)

ShortKeyFetch 获取托管的短key 注意:errcode = 0 为成功 shortKey:短key 文档:https://developers.weixin.qq.com/doc/offiaccount/Account_Management/KEY_Shortener.html

func (*SDK) ShortKeyGen

func (s *SDK) ShortKeyGen(c context.Context, body bm.BodyMap) (skg *ShortKeyGenRsp, err error)

ShortKeyGen 生成短key托管 注意:errcode = 0 为成功 文档:https://developers.weixin.qq.com/doc/offiaccount/Account_Management/KEY_Shortener.html

func (*SDK) UserTagBatchTagging

func (s *SDK) UserTagBatchTagging(c context.Context, tagId int, openidList []string) (err error)

UserTagBatchTagging 批量为用户打标签 注意:errcode = 0 为成功 文档:https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html

func (*SDK) UserTagBatchUnTagging

func (s *SDK) UserTagBatchUnTagging(c context.Context, tagId int, openidList []string) (err error)

UserTagBatchUnTagging 批量为用户取消标签 注意:errcode = 0 为成功 文档:https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html

func (*SDK) UserTagCreate

func (s *SDK) UserTagCreate(c context.Context, tagName string) (ut *UserTagRsp, err error)

UserTagCreate 用户标签创建 注意:errcode = 0 为成功 文档:https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html

func (*SDK) UserTagDelete

func (s *SDK) UserTagDelete(c context.Context, tagId int) (err error)

UserTagDelete 用户标签删除 注意:errcode = 0 为成功 文档:https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html

func (*SDK) UserTagFansList

func (s *SDK) UserTagFansList(c context.Context, tagId int, openid string) (utf *UserTagFansListRsp, err error)

UserTagFansList 获取标签下粉丝列表 注意:errcode = 0 为成功 openid:第一个拉取的 openid,不填默认从头开始拉取 文档:https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html

func (*SDK) UserTagIdList

func (s *SDK) UserTagIdList(c context.Context, openid string) (uti *UserTagIdListRsp, err error)

UserTagIdList 获取用户身上的标签列表 注意:errcode = 0 为成功 文档:https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html

func (*SDK) UserTagList

func (s *SDK) UserTagList(c context.Context) (utl *UserTagListRsp, err error)

UserTagList 获取已创建的用户标签列表 注意:errcode = 0 为成功 文档:https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html

func (*SDK) UserTagUpdate

func (s *SDK) UserTagUpdate(c context.Context, tagId int, tagName string) (err error)

UserTagUpdate 用户标签编辑更新 注意:errcode = 0 为成功 文档:https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html

type ShortKeyFetchRsp

type ShortKeyFetchRsp struct {
	Errcode       int        `json:"errcode,omitempty"`
	Errmsg        string     `json:"errmsg,omitempty"`
	LongData      string     `json:"long_data"`
	CreateTime    xtime.Time `json:"create_time"`
	ExpireSeconds int        `json:"expire_seconds"`
}

type ShortKeyGenRsp

type ShortKeyGenRsp struct {
	Errcode  int    `json:"errcode,omitempty"`
	Errmsg   string `json:"errmsg,omitempty"`
	ShortKey string `json:"short_key"`
}

type Tag

type Tag struct {
	Id    int    `json:"id"`
	Name  string `json:"name"`
	Count int    `json:"count"` // 此标签下粉丝数
}

type TicketRsp added in v1.1.5

type TicketRsp struct {
	Errcode   int    `json:"errcode,omitempty"`
	Errmsg    string `json:"errmsg,omitempty"`
	Ticket    string `json:"ticket,omitempty"`
	ExpiresIn int    `json:"expires_in,omitempty"` // 有效期7200秒,开发者必须在自己的服务全局缓存jsapi_ticket
}

type UserTagFansListRsp

type UserTagFansListRsp struct {
	Errcode    int       `json:"errcode,omitempty"`
	Errmsg     string    `json:"errmsg,omitempty"`
	Count      int       `json:"count"`
	NextOpenid string    `json:"next_openid,omitempty"`
	Data       *FansData `json:"data"`
}

type UserTagIdListRsp

type UserTagIdListRsp struct {
	Errcode   int    `json:"errcode,omitempty"`
	Errmsg    string `json:"errmsg,omitempty"`
	TagidList []int  `json:"tagid_list,omitempty"`
}

type UserTagListRsp

type UserTagListRsp struct {
	Errcode int    `json:"errcode,omitempty"`
	Errmsg  string `json:"errmsg,omitempty"`
	Tags    []*Tag `json:"tags,omitempty"`
}

type UserTagRsp

type UserTagRsp struct {
	Errcode int    `json:"errcode,omitempty"`
	Errmsg  string `json:"errmsg,omitempty"`
	Tag     *Tag   `json:"tag,omitempty"`
}

Jump to

Keyboard shortcuts

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