custom

package
v0.0.0-...-f5adc6c Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2014 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

定义客服主动回复消息的数据结构

Index

Constants

View Source
const (
	MSG_TYPE_TEXT  = "text"  // 文本消息
	MSG_TYPE_IMAGE = "image" // 图片消息
	MSG_TYPE_VOICE = "voice" // 语音消息
	MSG_TYPE_VIDEO = "video" // 视频消息
	MSG_TYPE_MUSIC = "music" // 音乐消息
	MSG_TYPE_NEWS  = "news"  // 图文消息
)
View Source
const (
	NewsArticleCountLimit = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CommonHead

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

type Image

type Image struct {
	CommonHead

	Image struct {
		MediaId string `json:"media_id"` // 通过上传多媒体文件得到的 MediaId
	} `json:"image"`
}

图片消息

func NewImage

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

新建图片消息

mediaId 是通过上传多媒体文件得到

type Music

type Music struct {
	CommonHead

	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"`        // 缩略图的媒体id, 通过上传多媒体文件得到
	} `json:"music"`
}

音乐消息

func NewMusic

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

新建音乐消息

thumbMediaId 通过上传多媒体文件得到
title, description 可以为 ""

type News

type News struct {
	CommonHead

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

图文消息

func NewNews

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

新建图文消息

NOTE: articles 的长度不能超过 NewsArticleCountLimit

func (*News) CheckValid

func (this *News) CheckValid() (err error)

检查 News 是否有效,有效返回 nil,否则返回错误信息

type NewsArticle

type NewsArticle 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

func (*NewsArticle) Init

func (this *NewsArticle) Init(title, description, url, picURL string)

type Text

type Text struct {
	CommonHead

	Text struct {
		Content string `json:"content"` // 支持换行符
	} `json:"text"`
}

文本消息

func NewText

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

新建文本消息

content 支持换行符

type Video

type Video struct {
	CommonHead

	Video struct {
		MediaId      string `json:"media_id"`              // 通过上传多媒体文件得到的 MediaId
		ThumbMediaId string `json:"thumb_media_id"`        // 缩略图的媒体id, 通过上传多媒体文件得到
		Title        string `json:"title,omitempty"`       // 视频消息的标题
		Description  string `json:"description,omitempty"` // 视频消息的描述
	} `json:"video"`
}

视频消息

func NewVideo

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

新建视频消息

mediaId, thumbMediaId 是通过上传多媒体文件得到
title, description 可以为 ""

type Voice

type Voice struct {
	CommonHead

	Voice struct {
		MediaId string `json:"media_id"` // 通过上传多媒体文件得到的 MediaId
	} `json:"voice"`
}

语音消息

func NewVoice

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

新建语音消息

mediaId 是通过上传多媒体文件得到

Jump to

Keyboard shortcuts

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