ASP提交表单发送短信通知函数
ASP提交表单成功后就发送短信通知函数,自己摸索了好几天,在这里分享给大家,希望对正在使用ASP网站程序,特别是ASPCMS的站长带来帮助。如果网站编码是gbk需要转换,,如果是编码是utf8/请注释c=toUTF8(c)。
ASP提交表单发送短信通知函数如下
Function sendsms() dim ac,authkey,m,cgid,csid,t,c,httpsendurl,xmlObj ac = ""'企业ID,请联系我们索取免费测试帐号 authkey = ""'认证密钥 m=filterPara(getForm("Mobile","post"))'发送手机号码 c = "恭喜您,报名成功,请等待富士康面试通知。请不要在其他途径重复报名,重复报名将不能参加面试。招聘热线13220383188"'发送内容 c=toUTF8(c)'gbk编码转换,本函数已经server.URLEncode,不需要再次url编码。如果是编码是utf8/请注释此行,同时server.URLEncode cgid="184"'发送所使用通道组 csid="3"'签名编号 ,可以为空时,使用系统默认的编号 t=""'发送时间,可以为空表示立即发送,yyyyMMddHHmmss 如:20130721182038 httpsendurl="http://smsapi.c123.cn/OpenPlatform/OpenApi?action=sendOnce&ac="&ac&"&authkey="&authkey&"&csid="&csid&"&cgid="&cgid&"&m="&m&"&c="&c Set xmlObj = server.CreateObject("Microsoft.XMLHTTP") xmlObj.Open "GET",httpsendurl,false xmlObj.send() sendSMS = xmlObj.responseText Set xmlObj = Nothing End Function 'gbk编码转成utf8编码 Function toUTF8(szInput) Dim wch, uch, szRet Dim x Dim nAsc, nAsc2, nAsc3 If szInput = "" Then toUTF8 = szInput Exit Function End If For x = 1 To Len(szInput) wch = Mid(szInput, x, 1) nAsc = AscW(wch) If nAsc < 0 Then nAsc = nAsc + 65536 If (nAsc And &HFF80) = 0 Then szRet = szRet & wch Else If (nAsc And &HF000) = 0 Then uch = "%" & Hex(((nAsc \ 2 ^ 6)) Or &HC0) & Hex(nAsc And &H3F Or &H80) szRet = szRet & uch Else uch = "%" & Hex((nAsc \ 2 ^ 12) Or &HE0) & "%" & _ Hex((nAsc \ 2 ^ 6) And &H3F Or &H80) & "%" & _ Hex(nAsc And &H3F Or &H80) szRet = szRet & uch End If End If Next toUTF8 = szRet End Function
中国五冶大学
写得不错,支持下