mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-08 06:32:27 +08:00
oauth2,jssdk
This commit is contained in:
17
message/image.go
Normal file
17
message/image.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package message
|
||||
|
||||
//Image 图片消息
|
||||
type Image struct {
|
||||
CommonToken
|
||||
|
||||
Image struct {
|
||||
MediaID string `xml:"MediaId"`
|
||||
} `xml:"Image"`
|
||||
}
|
||||
|
||||
//NewImage 回复图片消息
|
||||
func NewImage(mediaID string) *Image {
|
||||
image := new(Image)
|
||||
image.Image.MediaID = mediaID
|
||||
return image
|
||||
}
|
||||
@@ -46,6 +46,34 @@ const (
|
||||
EventView EventType = "VIEW"
|
||||
)
|
||||
|
||||
//MixMessage 存放所有微信发送过来的消息和事件
|
||||
type MixMessage struct {
|
||||
CommonToken
|
||||
|
||||
//基本消息
|
||||
MsgID int64 `xml:"MsgId"`
|
||||
Content string `xml:"Content"`
|
||||
PicURL string `xml:"PicUrl"`
|
||||
MediaID string `xml:"MediaId"`
|
||||
Format string `xml:"Format"`
|
||||
ThumbMediaID string `xml:"ThumbMediaId"`
|
||||
LocationX float64 `xml:"Location_X"`
|
||||
LocationY float64 `xml:"Location_Y"`
|
||||
Scale float64 `xml:"Scale"`
|
||||
Label string `xml:"Label"`
|
||||
Title string `xml:"Title"`
|
||||
Description string `xml:"Description"`
|
||||
URL string `xml:"Url"`
|
||||
|
||||
//事件相关
|
||||
Event string `xml:"Event"`
|
||||
EventKey string `xml:"EventKey"`
|
||||
Ticket string `xml:"Ticket"`
|
||||
Latitude string `xml:"Latitude"`
|
||||
Longitude string `xml:"Longitude"`
|
||||
Precision string `xml:"Precision"`
|
||||
}
|
||||
|
||||
//EncryptedXMLMsg 安全模式下的消息体
|
||||
type EncryptedXMLMsg struct {
|
||||
XMLName struct{} `xml:"xml" json:"-"`
|
||||
@@ -90,31 +118,3 @@ func (msg *CommonToken) SetCreateTime(createTime int64) {
|
||||
func (msg *CommonToken) SetMsgType(msgType MsgType) {
|
||||
msg.MsgType = msgType
|
||||
}
|
||||
|
||||
//MixMessage 存放所有微信发送过来的消息和事件
|
||||
type MixMessage struct {
|
||||
CommonToken
|
||||
|
||||
//基本消息
|
||||
MsgID int64 `xml:"MsgId"`
|
||||
Content string `xml:"Content"`
|
||||
PicURL string `xml:"PicUrl"`
|
||||
MediaID string `xml:"MediaId"`
|
||||
Format string `xml:"Format"`
|
||||
ThumbMediaID string `xml:"ThumbMediaId"`
|
||||
LocationX float64 `xml:"Location_X"`
|
||||
LocationY float64 `xml:"Location_Y"`
|
||||
Scale float64 `xml:"Scale"`
|
||||
Label string `xml:"Label"`
|
||||
Title string `xml:"Title"`
|
||||
Description string `xml:"Description"`
|
||||
URL string `xml:"Url"`
|
||||
|
||||
//事件相关
|
||||
Event string `xml:"Event"`
|
||||
EventKey string `xml:"EventKey"`
|
||||
Ticket string `xml:"Ticket"`
|
||||
Latitude string `xml:"Latitude"`
|
||||
Longitude string `xml:"Longitude"`
|
||||
Precision string `xml:"Precision"`
|
||||
}
|
||||
|
||||
24
message/music.go
Normal file
24
message/music.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package message
|
||||
|
||||
//Music 音乐消息
|
||||
type Music struct {
|
||||
CommonToken
|
||||
|
||||
Music struct {
|
||||
Title string `xml:"Title" `
|
||||
Description string `xml:"Description" `
|
||||
MusicURL string `xml:"MusicUrl" `
|
||||
HQMusicURL string `xml:"HQMusicUrl" `
|
||||
ThumbMediaID string `xml:"ThumbMediaId"`
|
||||
} `xml:"Music"`
|
||||
}
|
||||
|
||||
//NewMusic 回复音乐消息
|
||||
func NewMusic(title, description, musicURL, hQMusicURL, thumbMediaID string) *Music {
|
||||
music := new(Music)
|
||||
music.Music.Title = title
|
||||
music.Music.Description = description
|
||||
music.Music.MusicURL = musicURL
|
||||
music.Music.ThumbMediaID = thumbMediaID
|
||||
return music
|
||||
}
|
||||
35
message/news.go
Normal file
35
message/news.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package message
|
||||
|
||||
//News 图文消息
|
||||
type News struct {
|
||||
CommonToken
|
||||
|
||||
ArticleCount int `xml:"ArticleCount"`
|
||||
Articles []*Article `xml:"Articles>item,omitempty"`
|
||||
}
|
||||
|
||||
//NewNews 初始化图文消息
|
||||
func NewNews(articles []*Article) *News {
|
||||
news := new(News)
|
||||
news.ArticleCount = len(articles)
|
||||
news.Articles = articles
|
||||
return news
|
||||
}
|
||||
|
||||
//Article 单篇文章
|
||||
type Article struct {
|
||||
Title string `xml:"Title,omitempty"`
|
||||
Description string `xml:"Description,omitempty"`
|
||||
PicURL string `xml:"PicUrl,omitempty"`
|
||||
URL string `xml:"Url,omitempty"`
|
||||
}
|
||||
|
||||
//NewArticle 初始化文章
|
||||
func NewArticle(title, description, picURL, url string) *Article {
|
||||
article := new(Article)
|
||||
article.Title = title
|
||||
article.Description = description
|
||||
article.PicURL = picURL
|
||||
article.URL = url
|
||||
return article
|
||||
}
|
||||
@@ -5,3 +5,10 @@ type Text struct {
|
||||
CommonToken
|
||||
Content string `xml:"Content"`
|
||||
}
|
||||
|
||||
//NewText 初始化文本消息
|
||||
func NewText(content string) *Text {
|
||||
text := new(Text)
|
||||
text.Content = content
|
||||
return text
|
||||
}
|
||||
|
||||
21
message/video.go
Normal file
21
message/video.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package message
|
||||
|
||||
//Video 视频消息
|
||||
type Video struct {
|
||||
CommonToken
|
||||
|
||||
Video struct {
|
||||
MediaID string `xml:"MediaId"`
|
||||
Title string `xml:"Title,omitempty"`
|
||||
Description string `xml:"Description,omitempty"`
|
||||
} `xml:"Video"`
|
||||
}
|
||||
|
||||
//NewVideo 回复图片消息
|
||||
func NewVideo(mediaID, title, description string) *Video {
|
||||
video := new(Video)
|
||||
video.Video.MediaID = mediaID
|
||||
video.Video.Title = title
|
||||
video.Video.Description = description
|
||||
return video
|
||||
}
|
||||
17
message/voice.go
Normal file
17
message/voice.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package message
|
||||
|
||||
//Voice 语音消息
|
||||
type Voice struct {
|
||||
CommonToken
|
||||
|
||||
Voice struct {
|
||||
MediaID string `xml:"MediaId"`
|
||||
} `xml:"Voice"`
|
||||
}
|
||||
|
||||
//NewVoice 回复语音消息
|
||||
func NewVoice(mediaID string) *Voice {
|
||||
voice := new(Voice)
|
||||
voice.Voice.MediaID = mediaID
|
||||
return voice
|
||||
}
|
||||
Reference in New Issue
Block a user