要实现在asp网站上发送飞信,要求是中国移动的手机用户,并且开通移动飞信功能。
使用以下asp代码,修改参数为你的手机号及飞信密码,就可以实现在网站发免费短信功能。
fsend.asp文件源代码如下:
<%
Dim fno,fp,tofno,rurl
fno="138xxxxxxxx" '手机号
fp="xxxxxxxx" '飞信密码
tofno="137xxxxxxxx" '发送目标手机号(要求是自己的号码或飞信好友)
rurl="" '提交后转移到的目标地址(留空将不转移)
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>请留下你的联系信息</title>
</head>
<body style="font-size: 10pt; font-family: 宋体">
<%if (Request("msg")="") then%>
<form method="POST" action="fsend.asp">
<br>请留下你的联系信息<br>
<hr>
联系信息:<br><textarea rows="5" name="msg" cols="27"></textarea><br>
<p><input type="submit" value="提交" name="B1"></p>
</form>
<%
else
Dim returnString
Dim msg
msg=Request("msg")
returnString=sendf(fno,fp,tofno,msg)
if rurl="" then
Response.Write returnString&"<br><a href='fsend.asp'>返回</a>"
else
Response.Redirect rurl
end if
end if
%>
</body>
</html>
<%
function sendf(fno,fp,tofno,msg)
'函数参数说明:fno=登录手机号,fp=登录密码,tofno=目标手机号,msg=要发送的信息
Dim returnString
Dim SoapRequest
Dim SoapURL
SoapURL = "http://io2.139icq.com:88/send.aspx?fno="&fno&"&fp="&fp&"&tofno="&tofno&"&msg="&msg
Set SoapRequest = Server.CreateObject("MSXML2.XMLHTTP")
SoapRequest.Open "GET",SoapURL,False
SoapRequest.Send
returnString=bytes2bstr(SoapRequest.responsebody)
sendf=returnString
end function
function bytes2bstr(vin)
strreturn = ""
for i = 1 to lenb(vin)
thischarcode = ascb(midb(vin,i,1))
if thischarcode < &h80 then
strreturn = strreturn & chr(thischarcode)
else
nextcharcode = ascb(midb(vin,i+1,1))
strreturn = strreturn & chr(clng(thischarcode) * &h100 + cint(nextcharcode))
i = i + 1
end if
next
bytes2bstr = strreturn
end function
%>