custom

package
v0.0.0-...-ca6545e Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2016 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

客服消息.

Index

Constants

View Source
const (
	MsgTypeText   core.MsgType = "text"   // 文本消息
	MsgTypeImage  core.MsgType = "image"  // 图片消息
	MsgTypeVoice  core.MsgType = "voice"  // 语音消息
	MsgTypeVideo  core.MsgType = "video"  // 视频消息
	MsgTypeMusic  core.MsgType = "music"  // 音乐消息
	MsgTypeNews   core.MsgType = "news"   // 图文消息
	MsgTypeMPNews core.MsgType = "mpnews" // 图文消息, 发送已经创建好的图文
	MsgTypeWxCard core.MsgType = "wxcard" // 卡卷消息
)

Variables

This section is empty.

Functions

func Send

func Send(clt *core.Client, msg interface{}) (err error)

Send 发送消息, msg 是经过 encoding/json.Marshal 得到的结果符合微信消息格式的任何数据结构.

Types

type Article

type Article struct {
	Title       string `json:"title,omitempty"`       // 图文消息标题
	Description string `json:"description,omitempty"` // 图文消息描述
	URL         string `json:"url,omitempty"`         // 点击图文消息跳转链接
	PicURL      string `json:"picurl,omitempty"`      // 图文消息的图片链接, 支持JPG, PNG格式, 较好的效果为大图640*320, 小图80*80
}

图文消息里的 Article

type CustomService

type CustomService struct {
	KfAccount string `json:"kf_account"`
}

type Image

type Image struct {
	MsgHeader
	Image struct {
		MediaId string `json:"media_id"` // 通过素材管理接口上传多媒体文件得到 MediaId
	} `json:"image"`
	CustomService *CustomService `json:"customservice,omitempty"`
}

图片消息

func NewImage

func NewImage(toUser, mediaId, kfAccount string) (image *Image)

新建图片消息.

如果不指定客服则 kfAccount 留空.

type MPNews

type MPNews struct {
	MsgHeader
	MPNews struct {
		MediaId string `json:"media_id"` // 通过素材管理接口上传多媒体文件得到 MediaId
	} `json:"mpnews"`
	CustomService *CustomService `json:"customservice,omitempty"`
}

func NewMPNews

func NewMPNews(toUser, mediaId, kfAccount string) (mpnews *MPNews)

新建图文消息.

如果不指定客服则 kfAccount 留空.

type MsgHeader

type MsgHeader struct {
	ToUser  string       `json:"touser"` // 接收方 OpenID
	MsgType core.MsgType `json:"msgtype"`
}

type Music

type Music struct {
	MsgHeader
	Music struct {
		Title        string `json:"title,omitempty"`       // 音乐标题, 可以为 ""
		Description  string `json:"description,omitempty"` // 音乐描述, 可以为 ""
		MusicURL     string `json:"musicurl"`              // 音乐链接
		HQMusicURL   string `json:"hqmusicurl"`            // 高质量音乐链接, WIFI环境优先使用该链接播放音乐
		ThumbMediaId string `json:"thumb_media_id"`        // 通过素材管理接口上传多媒体文件得到 ThumbMediaId
	} `json:"music"`
	CustomService *CustomService `json:"customservice,omitempty"`
}

音乐消息

func NewMusic

func NewMusic(toUser, thumbMediaId, musicURL, HQMusicURL, title, description, kfAccount string) (music *Music)

新建音乐消息.

如果不指定客服则 kfAccount 留空.

type News

type News struct {
	MsgHeader
	News struct {
		Articles []Article `json:"articles,omitempty"` // 多条图文消息信息, 默认第一个item为大图, 注意, 如果图文数超过8, 则将会无响应
	} `json:"news"`
	CustomService *CustomService `json:"customservice,omitempty"`
}

图文消息

func NewNews

func NewNews(toUser string, articles []Article, kfAccount string) (news *News)

新建图文消息.

如果不指定客服则 kfAccount 留空.

type Text

type Text struct {
	MsgHeader
	Text struct {
		Content string `json:"content"` // 支持换行符
	} `json:"text"`
	CustomService *CustomService `json:"customservice,omitempty"`
}

文本消息

func NewText

func NewText(toUser, content, kfAccount string) (text *Text)

新建文本消息.

如果不指定客服则 kfAccount 留空.

type Video

type Video struct {
	MsgHeader
	Video struct {
		MediaId      string `json:"media_id"`              // 通过素材管理接口上传多媒体文件得到 MediaId
		ThumbMediaId string `json:"thumb_media_id"`        // 通过素材管理接口上传多媒体文件得到 ThumbMediaId
		Title        string `json:"title,omitempty"`       // 视频消息的标题, 可以为 ""
		Description  string `json:"description,omitempty"` // 视频消息的描述, 可以为 ""
	} `json:"video"`
	CustomService *CustomService `json:"customservice,omitempty"`
}

视频消息

func NewVideo

func NewVideo(toUser, mediaId, thumbMediaId, title, description, kfAccount string) (video *Video)

新建视频消息.

如果不指定客服则 kfAccount 留空.

type Voice

type Voice struct {
	MsgHeader
	Voice struct {
		MediaId string `json:"media_id"` // 通过素材管理接口上传多媒体文件得到 MediaId
	} `json:"voice"`
	CustomService *CustomService `json:"customservice,omitempty"`
}

语音消息

func NewVoice

func NewVoice(toUser, mediaId, kfAccount string) (voice *Voice)

新建语音消息.

如果不指定客服则 kfAccount 留空.

type WxCard

type WxCard struct {
	MsgHeader
	WxCard struct {
		CardId  string `json:"card_id"`
		CardExt string `json:"card_ext,omitempty"`
	} `json:"wxcard"`
	CustomService *CustomService `json:"customservice,omitempty"`
}

卡券消息, 特别注意客服消息接口投放卡券仅支持非自定义Code码的卡券

func NewWxCard

func NewWxCard(toUser, cardId, cardExt, kfAccount string) (card *WxCard)

新建卡券消息.

如果不指定客服则 kfAccount 留空.

Jump to

Keyboard shortcuts

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