trader

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MpVideoType = "mpvideo"

	AccessTokenURL         = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
	UploadURL              = "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token="
	AddNewsURL             = "https://api.weixin.qq.com/cgi-bin/material/add_news?access_token="
	SendMsgURL             = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token="
	CreateMenuURL          = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token="
	MaterialURL            = "https://api.weixin.qq.com/cgi-bin/material/"
	TypingURL              = "https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token="
	KFaccountURL           = "https://api.weixin.qq.com/customservice/kfaccount/"
	SetKfAccountheadimgURL = "http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?"
	GetkfListURL           = "https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token="
	Menu                   = "https://api.weixin.qq.com/cgi-bin/menu/"
	MediaURL               = "https://api.weixin.qq.com/cgi-bin/media/"
	SendAllURL             = "https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token="
	DeleteSendALLURL       = "https://api.weixin.qq.com/cgi-bin/message/mass/delete?access_token="
	PreviewURL             = "https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token="
	SendAllStatusURL       = "https://api.weixin.qq.com/cgi-bin/message/mass/get?access_token="
	MassSpeedURL           = "https://api.weixin.qq.com/cgi-bin/message/mass/speed/"
	TemplateURL            = "https://api.weixin.qq.com/cgi-bin/template/"
	TagsURL                = "https://api.weixin.qq.com/cgi-bin/tags/"
	CommentURL             = "https://api.weixin.qq.com/cgi-bin/comment/"
)

Variables

This section is empty.

Functions

func GetRandStr

func GetRandStr(a int) string

Types

type AccessToken

type AccessToken struct {
	Access_token string `json:"access_token"`
	Expires_in   int64  `json:"expires_in"`
}

type Article

type Article struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	Url         string `json:"url"`
	PicUrl      string `json:"picurl"`
}

type BassMessage

type BassMessage struct {
	Touser  string `json:"touser"`
	MsgType string `json:"msgtype"`
}

type Comment

type Comment struct {
	UserCommentID int    `json:"user_comment_id "`
	OpenID        string `json:"openid "`
	CreateTime    int    `json:"create_time "`
	Content       string `json:"content "`
	CommentType   int    `json:"comment_type "`
	Reply         struct {
		Content    string `json:"content "`
		CreateTime int    `json:"create_time "`
	} `json:"reply "`
}

评论

type Customservice

type Customservice struct {
	KFaccount string `json:"kf_account"`
}

type Fans

type Fans struct {
	Total      int    `json:"total"`
	Count      int    `json:"count"`
	NextOpenId string `json:"next_openid"`
	Data       struct {
		OpenId []string `json:"openid"`
	} `json:"data"`
}

type Handler

type Handler func() (AccessToken, error)

type Image

type Image struct {
	MediaId string `json:"media_id"`
}

type ImageMessage

type ImageMessage struct {
	BassMessage
	Image         Image         `json:"image"`
	Customservice Customservice `json:"customservice"`
}

type Jsapi_ticket

type Jsapi_ticket struct {
	ErrCode    int    `json:"errcode"`
	ErrMsg     string `json:"errmsg"`
	Ticket     string `json:"ticket"`
	Expires_in int64  `json:"Expires_in"`
}

type KF

type KF struct {
	KfAccount    string `json:"kf_account"`
	KfNick       string `json:"kf_nick"`
	KfId         string `json:"kf_id"`
	KfHeadImgUrl string `json:"kf_headimgurl"`
}

客服ZH账号

type KfAccountList

type KfAccountList struct {
	Kflist []KF `json:"kf_list"`
}

客服ZH账号

type Miniprogrampage

type Miniprogrampage struct {
	Title        string `json:"title"`
	AppId        string `json:"appid"`
	PagePath     string `json:"pagepath"`
	ThumbMediaId string `json:"thumb_media_id"`
}

type MiniprogrampageMessage

type MiniprogrampageMessage struct {
	BassMessage
	Miniprogrampage Miniprogrampage `json:"miniprogrampage"`
	Customservice   Customservice   `json:"customservice"`
}

type MpNews

type MpNews struct {
	MediaId string `json:"media_id"`
}

type MpNewsMessage

type MpNewsMessage struct {
	BassMessage
	MpNews        MpNews        `json:"mpnews"`
	Customservice Customservice `json:"customservice"`
}

type MpVideo

type MpVideo struct {
	MediaId string `json:"media_id"`
}

type Music

type Music struct {
	Title        string `json:"title"`
	Description  string `json:"description"`
	MusicUrl     string `json:"musicurl"`
	HqmusicUrl   string `json:"hqmusicurl"`
	ThumbMediaId string `json:"thumb_media_id"`
}

type MusicMessage

type MusicMessage struct {
	BassMessage
	Music         Music         `json:"music"`
	Customservice Customservice `json:"customservice"`
}

type News

type News struct {
	Articles []Article `json:"articles"`
}

type NewsArticle

type NewsArticle struct {
	Title              string `json:"title"`
	ThumbMediaId       string `json:"thumb_media_id"`
	Author             string `json:"author"`
	Digest             string `json:"digest"`
	ShowCoverPic       int    `json:"show_cover_pic"`
	Content            string `json:"content"`
	ContentSourceUrl   string `json:content_source_url`
	NeedOpenComment    int    `json:"need_open_comment"`
	OnlyFansCanComment int    `json:"only_fans_can_comment"`
}

type NewsList

type NewsList struct {
	Articles []NewsArticle `json:"articles"`
}

type NewsMessage

type NewsMessage struct {
	BassMessage
	News          News          `json:"news"`
	Customservice Customservice `json:"customservice"`
}

type PreviewImage

type PreviewImage struct {
	ToUser  string `json:"touser"`
	Image   Image  `json:"image"`
	MsgType string `json:"msgtype"`
}

群发预览结构体

type PreviewMpNews

type PreviewMpNews struct {
	ToUser  string `json:"touser"`
	MpNews  MpNews `json:"mpnews"`
	MsgType string `json:"msgtype"`
}

群发预览结构体

type PreviewMpVideo

type PreviewMpVideo struct {
	ToUser  string  `json:"touser"`
	MpVideo MpVideo `json:"mpvideo"`
	MsgType string  `json:"msgtype"`
}

群发预览结构体

type PreviewText

type PreviewText struct {
	ToUser  string `json:"touser"`
	Text    Text   `json:"text"`
	MsgType string `json:"msgtype"`
}

群发预览结构体

type PreviewVoice

type PreviewVoice struct {
	ToUser  string `json:"touser"`
	Voice   Voice  `json:"voice"`
	MsgType string `json:"msgtype"`
}

群发预览结构体

type Res

type Res struct {
	ErrCode int    `json:"errcode"`
	ErrMsg  string `json:"errmsg"`
}

type SendAllResp

type SendAllResp struct {
	ErrCode   int    `json:"errcode"`
	ErrMsg    string `json:"errmsg"`
	MsgId     int    `json:"msg_id"`
	MsgDataId int    `json:"206227730"`
}

type Tag

type Tag struct {
	Id    int    `json:"id"`
	Name  string `json:"name"`
	Count int    `json:"count"`
}

标签

type Text

type Text struct {
	Content string `json:"content"`
}

type TextMessage

type TextMessage struct {
	BassMessage
	Text          Text          `json:"text"`
	Customservice Customservice `json:"customservice"`
}

type Trader

type Trader struct {
	AppId                string
	AppSecret            string
	Accesstoken          string
	ExpiresIn            int64
	JsapiTicket          string
	JsapiTicketExpiresIn int64

	AccessTokenHandler Handler
	// contains filtered or unexported fields
}

func NewTrader

func NewTrader(appid, appsecret string, h Handler) (t *Trader, err error)

func (*Trader) AddConditionalMenu

func (t *Trader) AddConditionalMenu(menujson string) (menuid string, err error)

创建个性化菜单

func (*Trader) AddImageMaterial

func (t *Trader) AddImageMaterial(data []byte) (mediaId, url string, err error)

func (*Trader) AddKfAccount

func (t *Trader) AddKfAccount(kfaccount, nickname, password string) error

添加客服账号

func (*Trader) AddNews

func (t *Trader) AddNews(nl NewsList) (mediaId string, err error)

新增永久图文素材

func (*Trader) AddThumbMaterial

func (t *Trader) AddThumbMaterial(data []byte) (mediaId, url string, err error)

func (*Trader) AddVideoMaterial

func (t *Trader) AddVideoMaterial(data []byte, title, introduction string) (mediaId string, err error)

func (*Trader) AddVoiceMaterial

func (t *Trader) AddVoiceMaterial(data []byte) (mediaId string, err error)

func (*Trader) BatchCancelTag

func (t *Trader) BatchCancelTag(useropenid []string, tagid int) (err error)

批量为用户取消标签

func (*Trader) BatchGetMaterial

func (t *Trader) BatchGetMaterial(materialtype string, offset int, count int) (data string, err error)

获取素材列表详情

type 素材的类型,图片(image)、视频(video)、语音 (voice)、图文(news)
offset 从全部素材的该偏移位置开始返回,0表示从第一个素材 返回
count 返回素材的数量,取值在1到20之间
data 返回的json字符串 需要自己解析

func (*Trader) BatchTagToUsers

func (t *Trader) BatchTagToUsers(useropenids []string, tagid int) (err error)

批量为用户打标签

func (*Trader) CheckAccessTokenLive

func (t *Trader) CheckAccessTokenLive() (err error)

func (*Trader) CreateMenu

func (t *Trader) CreateMenu(contentjson string) (err error)

创建菜单 参数为菜单json字符串

func (*Trader) CreateTag

func (t *Trader) CreateTag(tagname string) (tagid int, err error)
用户管理

创建标签

func (*Trader) DelKfAccount

func (t *Trader) DelKfAccount(kfaccount, nickname, password string) error

删除客服账号

func (*Trader) DelMaterial

func (t *Trader) DelMaterial(mediaid string) (err error)

删除永久素材

func (*Trader) DelMenu

func (t *Trader) DelMenu() (err error)

删除菜单

func (*Trader) DelTag

func (t *Trader) DelTag(tagid int) (err error)

删除标签

func (*Trader) DelTemplate

func (t *Trader) DelTemplate(templateId string) (err error)

删除模板

func (*Trader) DelconditionalMenu

func (t *Trader) DelconditionalMenu(menuid string) (err error)

删除个性化菜单

func (*Trader) DeleteComment

func (t *Trader) DeleteComment(msgdataid, index, usercommentid int) (err error)

删除评论

func (*Trader) DeleteMass

func (t *Trader) DeleteMass(msgid, index int) (err error)

删除群发【订阅号与服务号认证后均可用】 index 第一篇编号为1,该字段填0会删除全部文章

func (*Trader) DeleteReplyComment

func (t *Trader) DeleteReplyComment(msgdataid, index, usercommentid int) (err error)

删除回复

func (*Trader) FlushAccessToken

func (t *Trader) FlushAccessToken() (err error)

func (*Trader) Get

func (t *Trader) Get(surl string) (b []byte, err error)

func (*Trader) GetALLTemplate

func (t *Trader) GetALLTemplate() (jsonstr string, err error)

获取模板列表 return josn字符串

func (*Trader) GetAccessToken

func (t *Trader) GetAccessToken() (a AccessToken, err error)

func (*Trader) GetCommentList

func (t *Trader) GetCommentList(msgdataid, index, begin, count, commenttype int) (list []Comment, err error)

查看指定文章的评论数据

参数 说明 msg_data_id 群发返回的msg_data_id index 多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文 begin 起始位置 count 获取数目(>=50会被拒绝) type type=0 普通评论&精选评论type=1 普通评论 type=2 精选评论

func (*Trader) GetFans

func (t *Trader) GetFans(nextopenid string) (fans Fans, err error)

获取用户列表

nextopenid 第一个拉取的OPENID,填空默认从头开始拉取 附:关注者数量超过10000时 当公众号关注者数量超过10000时,可通过填写next_openid的值,从而多次拉取列表的方式来满足需求。

func (*Trader) GetIndustry

func (t *Trader) GetIndustry() (jsonstr string, err error)

获取设置的行业信息

func (*Trader) GetJsapiTicket

func (t *Trader) GetJsapiTicket() (ticket string, err error)

func (*Trader) GetKfList

func (t *Trader) GetKfList() (list KfAccountList, err error)

获取所有客服账号

func (*Trader) GetMassSpeed

func (t *Trader) GetMassSpeed() (speedgrade, realspeed int, err error)

获取群发速度

func (*Trader) GetMaterialCount

func (t *Trader) GetMaterialCount() (newscount, imagecount, videocount, voicecount int, err error)

获取素材总数

func (*Trader) GetMaterialInfo

func (t *Trader) GetMaterialInfo(mediaid string) (data []byte, err error)

获取永久素材内容

func (*Trader) GetMenu

func (t *Trader) GetMenu() (menujson string, err error)

获取菜单 得到菜单json字符串

func (*Trader) GetSendAllStatus

func (t *Trader) GetSendAllStatus(msgid int) (status string, err error)

查询群发消息发送状态【订阅号与服务号认证后均可用】 status 消息发送后的状态,SEND_SUCCESS表示发送成功,SENDING表示发送中,SEND_FAIL表示发送失败,DELETE表示已删除

func (*Trader) GetTag

func (t *Trader) GetTag() (tags []Tag, err error)

获取公众号已创建的标签

func (*Trader) GetTagsByUser

func (t *Trader) GetTagsByUser(useropenid string) (tagids []int, err error)

获取用户身上的标签列表

func (*Trader) GetTemplateId

func (t *Trader) GetTemplateId(templateIdShort string) (templateId string, err error)

获得模板ID

func (*Trader) GetUserByTag

func (t *Trader) GetUserByTag(tagid int, nextopenid string) (useropenid []string, lastopenid string, err error)

获取标签下粉丝列表

tagid 标签id, nextopenid 第一个拉取的OPENID,不填默认从头开始拉取

func (*Trader) GetUserInfo

func (t *Trader) GetUserInfo(openid string) (user UserInfo, err error)

获取用户基本信息(包括UnionID机制)

func (*Trader) MarkelectComment

func (t *Trader) MarkelectComment(msgdataid, index, usercommentid int) (err error)

将评论标记精选

func (*Trader) OpenComment

func (t *Trader) OpenComment(bl bool, msgdataid int, index int) (err error)

打开/关闭已群发文章评论 msgdataid 由SendMpNewsAll返回的字段 bl ture为开启 fasle为关闭

func (*Trader) PostJson

func (t *Trader) PostJson(surl, jsonstr string) (b []byte, err error)

func (*Trader) Preview

func (t *Trader) Preview(msgtype string, useropenid, mediaId string) (err error)

预览接口【订阅号与服务号认证后均可用】

func (*Trader) ReplyComment

func (t *Trader) ReplyComment(msgdataid, index, usercommentid int, content string) (err error)

回复评论

func (*Trader) SendImageAll

func (t *Trader) SendImageAll(tagId int, mediaId string) (msgid int, err error)

群发图片

func (*Trader) SendImageMsg

func (t *Trader) SendImageMsg(touser, imgMediaId string) error

func (*Trader) SendMPNews

func (t *Trader) SendMPNews(touser, mediaId string) error

func (*Trader) SendMiniProgrampageMsg

func (t *Trader) SendMiniProgrampageMsg(touser, title, appid, pagePath, thumbMediaId string) error

func (*Trader) SendMpNewsAll

func (t *Trader) SendMpNewsAll(tagId int, mediaId string) (msgid, msgdataid int, err error)

群发图文

func (*Trader) SendMusicMsg

func (t *Trader) SendMusicMsg(touser, title, description, musicurl, hqmusicurl, thumb_media_id string) error

func (*Trader) SendNewsMsg

func (t *Trader) SendNewsMsg(touser string, articles []Article) error

func (*Trader) SendTemplateMsg

func (t *Trader) SendTemplateMsg(jsonContext string) (msgid int, err error)

发送模板消息

func (*Trader) SendTextAll

func (t *Trader) SendTextAll(tagId int, text string) (msgid int, err error)

群发文本消息

func (*Trader) SendTextMsg

func (t *Trader) SendTextMsg(touser, text string) error

func (*Trader) SendVideoAll

func (t *Trader) SendVideoAll(tagId int, mediaId, title, description string) (msgid int, err error)

群发视频

func (*Trader) SendVideoMsg

func (t *Trader) SendVideoMsg(touser, videoMediaId, thumbMediaId, title, description string) error

func (*Trader) SendVoiceAll

func (t *Trader) SendVoiceAll(tagId int, mediaId string) (msgid int, err error)

群发语音

func (*Trader) SendVoiceMsg

func (t *Trader) SendVoiceMsg(touser, voiceMediaId string) error

func (*Trader) SendWxCardAll

func (t *Trader) SendWxCardAll(tagId int, cardId string) (msgid int, err error)

群发卡券消息

func (*Trader) SendWxCardMsg

func (t *Trader) SendWxCardMsg(touser, cardId string) error

func (*Trader) SetIndustry

func (t *Trader) SetIndustry(industryId1, industryId2 int) (err error)

设置所属行业

func (*Trader) SetJsapiTicket

func (t *Trader) SetJsapiTicket(ticket string, Expires_in int64)

func (*Trader) SetKfAccountheadImg

func (t *Trader) SetKfAccountheadImg(kfaccount string, imgdata []byte) (err error)

设置客服账号头像

func (*Trader) SetMassSpeed

func (t *Trader) SetMassSpeed(speed int) (err error)

设置群发速度 speed 只能是0到4的整数

func (*Trader) SetRemark

func (t *Trader) SetRemark(useropenid string, remark string) (err error)

设置用户备注名

func (*Trader) Typing

func (t *Trader) Typing(touser string, b bool) (err error)

开关客服输入状态

func (*Trader) UnMarkelectComment

func (t *Trader) UnMarkelectComment(msgdataid, index, usercommentid int) (err error)

将评论取消精选

func (*Trader) UpLoadImg

func (t *Trader) UpLoadImg(data []byte) (url string, err error)

上传图文消息内的图片获取URL【订阅号与服务号认证后均可用】

func (*Trader) UpdateKfAccount

func (t *Trader) UpdateKfAccount(kfaccount, nickname, password string) error

修改客服账号

func (*Trader) UpdateNews

func (t *Trader) UpdateNews(mediaid string, index int, article NewsArticle) (err error)

修改永久图文素材 index:要更新的文章在图文消息中的位置(多图文消息时,此字段才有意义),第一篇为0

func (*Trader) UpdateTag

func (t *Trader) UpdateTag(tagid int, tagname string) (err error)

编辑标签

func (*Trader) UploadNews

func (t *Trader) UploadNews(articles []NewsArticle) (mediaId string, err error)

上传图文消息素材【订阅号与服务号认证后均可用】

func (*Trader) WebConfig

func (t *Trader) WebConfig(url string) (wf WebConf, err error)

type UserInfo

type UserInfo struct {
	Subscribe     int    `json:"subscribe"`
	Openid        string `json:"openid"`
	NickName      string `json:"nickname"`
	Sex           int    `json:"sex"`
	Language      string `json:"language"`
	City          string `json:"city"`
	Province      string `json:"province"`
	Country       string `json:"country"`
	HeadimgUrl    string `json:"headimgurl"`
	SubscribeTime int64  `json:"subscribe_time"`
	Unionid       string `json:"unionid"`
	Remark        string `json:"remark"`
	Groupid       int    `json:"groupid"`
	TagidList     []int  `json:"tagid_list"`
}

用户信息

type Video

type Video struct {
	MediaId      string `json:"media_id"`
	ThumbMediaId string `json:"thumb_media_id"`
	Title        string `json:"title"`
	Description  string `json:"description"`
}

type VideoDesc

type VideoDesc struct {
	Title        string `json:"title"`
	Introduction string `json:"introduction"`
}

type VideoMessage

type VideoMessage struct {
	BassMessage
	Video         Video         `json:"video"`
	Customservice Customservice `json:"customservice"`
}

type Voice

type Voice struct {
	MediaId string `json:"media_id"`
}

type VoiceMessage

type VoiceMessage struct {
	BassMessage
	Voice         Voice         `json:"voice"`
	Customservice Customservice `json:"customservice"`
}

type WebConf

type WebConf struct {
	AppId     string
	Timestamp int64
	Noncestr  string
	Signature string
}

type WxCard

type WxCard struct {
	CardId string `json:"card_id"`
}

type WxCardMessage

type WxCardMessage struct {
	BassMessage
	WxCard        WxCard        `json:"wxcard"`
	Customservice Customservice `json:"customservice"`
}

Jump to

Keyboard shortcuts

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