-
Notifications
You must be signed in to change notification settings - Fork 13
this.reply回复对象详细信息及案例
51Ding edited this page May 7, 2018
·
1 revision
- 文本消息(text)
- 图片消息(image)
- 语音消息(voice)
- 视频消息(video)
- 音乐消息(music)
- 图文消息(news)
this.reply={
type:"text",
content:"回复的文本内容"
}
this.reply={
type:"image",
content:{
mediaid:"通过素材管理中的接口上传多媒体文件,得到的id。"
}
}
this.reply={
type:"voice",
content:{
mediaid:"通过素材管理中的接口上传多媒体文件,得到的id。"
}
}
this.reply={
type:"video",
content:{
mediaid:"通过素材管理中的接口上传多媒体文件,得到的id。",
title:"视频标题",
description:"视频描述"
}
}
this.reply={
type:"music",
content:{
title:"音乐标题",
description:"音乐的描述",
MUSIC_Url:"音乐的链接",
HQ_MUSIC_Url:"高质量音乐链接,在wifi环境下,优先使用这个链接",
ThumbMediaId:"缩略图的媒体id,通过素材接口获取到的id"
}
}
**图文消息需要特别说明一下,图文消息的content属性必须是一个【数组】,这里的图文实际上指的是多图文,图文数不能超过8,即 content.length<=8 **
this.reply={
type:"news",
content:[{
title:"图文消息的标题",
description:"图文消息描述",
picurl:"图片链接,支持JPG、PNG格式,较好的效果为大图360*200,小图200*200",
url:"点击图文消息跳转链接"
},{
title:"",
description:"",
picurl:"",
url:""
}]
}
里边有一些多媒体的id,大家没有的话可能无法测试
app.use(wechat({
appID:"",
appsecret:"",
token:""
},async function () {
var message=this.message;
var wechat=this.wechat;
console.log(message);
if(message.MsgType=="text"){
//回复文本消息
if(message.Content==1){
this.reply={
type:"text",
content:"回复的文本内容"
}
}
else if(message.Content==2){
this.reply={
type:"image",
content:{
mediaid:"mB7xGVnSxP7gYUFrO4AWiBwJ75xarfktZihxjAnejafc9thcioKtNuDtm5lnrCqa"
}
}
}
else if(message.Content==3){
this.reply={
type:"voice",
content:{
mediaid:"ILZ2gSlgltb9sw8FV8quH-KIwCzBlzQxp4bdys3yaux7V6_CZGDFY_o7weT5YaAH"
}
}
}
else if(message.Content==4){
this.reply={
type:"video",
content:{
mediaid:"MeOhqAIKN6DTALRERW19eq6E-xmcvBG1hSvBYQqwAoK1JWfcOFXva4b_M5GhdbgM",
title:"视频标题",
description:"视频描述"
}
}
}
else if(message.Content==5){
this.reply={
type:"music",
content:{
title:"音乐标题",
description:"音乐的描述",
MUSIC_Url:"http://win.web.ri01.sycdn.kuwo.cn/8890c802945d78a2f7456e05ca4e4922/5aeebd44/resource/n1/12/26/3683856931.mp3",
ThumbMediaId:"_CDwFnJm3_TauWDSkmm2Jmb4f_3mpgonMzEvacdVGqZ2_sUPHwCAesPmDdhQ4Nfl"
}
}
}
else if(message.Content==6){
this.reply={
type:"news",
content:[{
title:"Github",
description:"koa-easywechat",
picurl:"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1526194643&di=ec73dcd5cb6a12e1d38984c612edaaae&imgtype=jpg&er=1&src=http%3A%2F%2Fpic34.photophoto.cn%2F20150313%2F0005018304394138_b.jpg",
url:"https://github.com/51ding/koa-easywechat"
},{
title:"Github",
description:"",
picurl:"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1526194643&di=ec73dcd5cb6a12e1d38984c612edaaae&imgtype=jpg&er=1&src=http%3A%2F%2Fpic34.photophoto.cn%2F20150313%2F0005018304394138_b.jpg",
url:"https://github.com/51ding/koa-easywechat"
}]
}
}
else if(message.Content==7){
var mediaId=await wechat.uploadTemporaryMaterial("video","./1.mp4");
console.log("mediaId:",mediaId);
}
else{
var token=await wechat.getAccessToken();
this.reply={
type:"text",
content:token
}
}
}
}));