微信asp+sqlser开发实例——回复消息

根据微信http://mp.weixin.qq.com/wiki/index.php 接收消息提供的接口,微信提供多种消息回复接口,本人开发调试过程一一封装,下边是封装好的方法,希望对大家有帮助。


这里做个广告,为了更快了解微信本来新建了一个QQ群,群名称是【微信开发技术交流:389075177】,专门用于微信开发和交流,欢迎正在研究微信的童鞋一起加入,一起学习,一起进步!


'回复文本消息
function text(fromusername,tousername,returnstr)
text="<xml>" &_
"<ToUserName><![CDATA["&fromusername&"]]></ToUserName>" &_
"<FromUserName><![CDATA["&tousername&"]]></FromUserName>" &_
"<CreateTime>"&now&"</CreateTime>" &_
"<MsgType><![CDATA[text]]></MsgType>" &_
"<Content><![CDATA[" & Replace(returnstr,"<br>",VBCRLF) & "]]></Content>" &_
"<FuncFlag>0<FuncFlag>" &_
"</xml>"
end Function


'回复图片消息
function image(fromusername,tousername,media_id)
image="<xml>" &_
"<ToUserName><![CDATA["&fromusername&"]]></ToUserName>" &_
"<FromUserName><![CDATA["&tousername&"]]></FromUserName>" &_
"<CreateTime>"&now&"</CreateTime>" &_
"<MsgType><![CDATA[image]]></MsgType>" &_
"<Image>" &_
"<MediaId><![CDATA["&media_id&"]]></MediaId>>" &_
"</Image>" &_
"</xml>"
end Function


'回复语音消息
function voice(fromusername,tousername,media_id)
voice="<xml>" &_
"<ToUserName><![CDATA["&fromusername&"]]></ToUserName>" &_
"<FromUserName><![CDATA["&tousername&"]]></FromUserName>" &_
"<CreateTime>"&now&"</CreateTime>" &_
"<MsgType><![CDATA[voice]]></MsgType>" &_
"<Voice>" &_
"<MediaId><![CDATA["&media_id&"]]></MediaId>>" &_
"</Voice>" &_
"</xml>"
end Function


'回复视频消息

function video(fromusername,tousername,media_id,title,description)
video="<xml>" &_
"<ToUserName><![CDATA["&fromusername&"]]></ToUserName>" &_
"<FromUserName><![CDATA["&tousername&"]]></FromUserName>" &_
"<CreateTime>"&now&"</CreateTime>" &_
"<MsgType><![CDATA[video]]></MsgType>" &_
"<Video>" &_
"<MediaId><![CDATA["&media_id&"]]></MediaId>" &_
"<Title><![CDATA["&title&"]]></Title>" &_
"<Description><![CDATA["&description&"]]></Description>" &_
"</Video>" &_
"</xml>"
end Function


'回复音乐消息
function music(fromusername,tousername,title,description,musicurl,hqmusicurl,media_id)
music="<xml>" &_
"<ToUserName><![CDATA["&fromusername&"]]></ToUserName>" &_
"<FromUserName><![CDATA["&tousername&"]]></FromUserName>" &_
"<CreateTime>"&now&"</CreateTime>" &_
"<MsgType><![CDATA[music]]></MsgType>" &_
"<Music>" &_
"<Title><![CDATA["&title&"]]></Title>" &_
"<Description><![CDATA["&description&"]]></Description>" &_
"<MusicUrl><![CDATA["&musicurl&"]]></MusicUrl>" &_
"<HQMusicUrl><![CDATA["&hqmusicurl&"]]></HQMusicUrl>" &_
"<MediaId><![CDATA["&media_id&"]]></MediaId>>" &_
"</Music>" &_
"</xml>"
end Function


'回复图文消息
function news(fromusername,tousername,Articles)
news="<xml>" &_
"<ToUserName><![CDATA["&fromusername&"]]></ToUserName>" &_
"<FromUserName><![CDATA["&tousername&"]]></FromUserName>" &_
"<CreateTime>"&now&"</CreateTime>" &_
"<MsgType><![CDATA[news]]></MsgType>" 
Dim rs,sql
set rs=server.CreateObject("adodb.recordset")
sql="select * from WeiXin_NewsItem where Articles="&Articles
rs.open sql,conn,1,3
news=news&"<ArticleCount>"&rs.recordcount&"</ArticleCount>"
news=news&"<Articles>"
Do While Not rs.eof
news=news&"<item>"
news=news&"<Title><![CDATA["&rs("Title")&"]]></Title>"
news=news&"<PicUrl><![CDATA["&rs("PicUrl")&"]]></PicUrl>"
news=news&"<Url><![CDATA["&rs("Url")&"]]></Url>"
news=news&"</item>"
rs.movenext
Loop
rs.close
Set rs=nothing
news=news&"</Articles>"
news=news&"</xml>"
End function

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值