response

package
v0.0.0-...-4877452 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2015 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

被动回复用户消息.

Index

Constants

View Source
const (
	MsgTypeText                    = "text"                      // 文本消息
	MsgTypeImage                   = "image"                     // 图片消息
	MsgTypeVoice                   = "voice"                     // 语音消息
	MsgTypeVideo                   = "video"                     // 视频消息
	MsgTypeMusic                   = "music"                     // 音乐消息
	MsgTypeNews                    = "news"                      // 图文消息
	MsgTypeTransferCustomerService = "transfer_customer_service" // 将消息转发到多客服
)
View Source
const (
	NewsArticleCountLimit = 10 // 被动回复图文消息的文章数据最大数
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	Title       string `xml:"Title,omitempty"       json:"Title,omitempty"`       // 图文消息标题
	Description string `xml:"Description,omitempty" json:"Description,omitempty"` // 图文消息描述
	PicURL      string `xml:"PicUrl,omitempty"      json:"PicUrl,omitempty"`      // 图片链接, 支持JPG, PNG格式, 较好的效果为大图360*200, 小图200*200
	URL         string `xml:"Url,omitempty"         json:"Url,omitempty"`         // 点击图文消息跳转链接
}

图文消息里的 Article

type Image

type Image struct {
	XMLName struct{} `xml:"xml" json:"-"`
	mp.CommonMessageHeader

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

图片消息

func NewImage

func NewImage(to, from string, timestamp int64, mediaId string) (image *Image)

新建图片消息

MediaId 通过上传多媒体文件得到

type Music

type Music struct {
	XMLName struct{} `xml:"xml" json:"-"`
	mp.CommonMessageHeader

	Music struct {
		Title        string `xml:"Title,omitempty"        json:"Title,omitempty"`        // 音乐标题
		Description  string `xml:"Description,omitempty"  json:"Description,omitempty"`  // 音乐描述
		MusicURL     string `xml:"MusicUrl,omitempty"     json:"MusicUrl,omitempty"`     // 音乐链接
		HQMusicURL   string `xml:"HQMusicUrl,omitempty"   json:"HQMusicUrl,omitempty"`   // 高质量音乐链接, WIFI环境优先使用该链接播放音乐
		ThumbMediaId string `xml:"ThumbMediaId,omitempty" json:"ThumbMediaId,omitempty"` // 缩略图的媒体id, 通过上传多媒体文件得到
	} `xml:"Music" json:"Music"`
}

音乐消息

func NewMusic

func NewMusic(to, from string, timestamp int64, thumbMediaId, musicURL,
	HQMusicURL, title, description string) (music *Music)

新建音乐消息

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

type News

type News struct {
	XMLName struct{} `xml:"xml" json:"-"`
	mp.CommonMessageHeader

	ArticleCount int       `xml:"ArticleCount"            json:"ArticleCount"`       // 图文消息个数, 限制为10条以内
	Articles     []Article `xml:"Articles>item,omitempty" json:"Articles,omitempty"` // 多条图文消息信息, 默认第一个item为大图, 注意, 如果图文数超过10, 则将会无响应
}

图文消息

func NewNews

func NewNews(to, from string, timestamp int64, articles []Article) (news *News)

NOTE: articles 的长度不能超过 NewsArticleCountLimit

func (*News) CheckValid

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

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

type Text

type Text struct {
	XMLName struct{} `xml:"xml" json:"-"`
	mp.CommonMessageHeader

	Content string `xml:"Content" json:"Content"` // 回复的消息内容, 支持换行符
}

文本消息

func NewText

func NewText(to, from string, timestamp int64, content string) (text *Text)

新建文本消息

NOTE: content 支持换行符

type TransInfo

type TransInfo struct {
	KfAccount string `xml:"KfAccount" json:"KfAccount"`
}

type TransferToCustomerService

type TransferToCustomerService struct {
	XMLName struct{} `xml:"xml" json:"-"`
	mp.CommonMessageHeader

	*TransInfo `xml:"TransInfo,omitempty" json:"TransInfo,omitempty"`
}

将消息转发到多客服

func NewTransferToCustomerService

func NewTransferToCustomerService(to, from string, timestamp int64, kfAccount string) (msg *TransferToCustomerService)

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

type Video

type Video struct {
	XMLName struct{} `xml:"xml" json:"-"`
	mp.CommonMessageHeader

	Video struct {
		MediaId     string `xml:"MediaId"               json:"MediaId"`               // MediaId 通过上传多媒体文件得到
		Title       string `xml:"Title,omitempty"       json:"Title,omitempty"`       // 视频消息的标题
		Description string `xml:"Description,omitempty" json:"Description,omitempty"` // 视频消息的描述
	} `xml:"Video" json:"Video"`
}

视频消息

func NewVideo

func NewVideo(to, from string, timestamp int64, mediaId, title, description string) (video *Video)

新建视频消息

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

type Voice

type Voice struct {
	XMLName struct{} `xml:"xml" json:"-"`
	mp.CommonMessageHeader

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

语音消息

func NewVoice

func NewVoice(to, from string, timestamp int64, mediaId string) (voice *Voice)

新建语音消息

MediaId 通过上传多媒体文件得到

Jump to

Keyboard shortcuts

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