预先感谢您。谁能帮我解决这个问题,我需要从回调URL获取值。回调URL如下所示。回调URL中的参数是由第三方发送的。
"https://www.viewmyrecord.com/Texting/GetReply.asp?from=1561234567&to=15698745642&text=Hi
Kid,Reminder November 22, 2019 w/ REN, MD at 11:00 am&datetime=Nov 11 2019 10:17PM&cost=0.00"
我需要解析“ from”,“ to”,“ text”,“ datetime”和“ cost”的值。并将其保存到文本文件。我对此一无所知。但是我的“ GetReply.asp”看起来像这样。
<%
If Request.TotalBytes > 0 Then
Dim lngBytesCount,try
lngBytesCount = Request.TotalBytes
Response.Write BytesToStr(Request.BinaryRead(lngBytesCount))
dim fs,tfile,loc,locadd,loctime,loctime1,nameFile,datename
datDate = Now()
locadd = Trim(FormatDateTime(datDate, 1))
loctime = FormatDateTime(datDate, 4)
loctime1 = stripNonNumeric(FormatDateTime(Now, 3))
nameFile = "\\85new\Accts85new\Texting\Reply\"
datename = Trim(loctime1&"-"&locadd&".txt")
loc = "\\85new\Accts85new\Texting\Reply\"&loctime1&"-"&locadd&".txt"
set fs=Server.CreateObject("Scripting.FileSystemObject")
set tfile=fs.CreateTextFile(loc)
tfile.WriteLine(try)
tfile.close
set tfile=nothing
set fs=nothing
end if
Function BytesToStr(bytes)
Dim Stream
Set Stream = Server.CreateObject("Adodb.Stream")
Stream.Type = 1 'adTypeBinary
Stream.Open
Stream.Write bytes
Stream.Position = 0
Stream.Type = 2 'adTypeText
Stream.Charset = "iso-8859-1"
BytesToStr = Stream.ReadText
try = BytesToStr
Stream.Close
Set Stream = Nothing
End Function
Function stripNonNumeric(inputString)
Set regEx = New RegExp
regEx.Global = True
regEx.Pattern = "\D"
stripNonNumeric = regEx.Replace(inputString,"")
End Function
%>
关于那个“ GetReply.asp”,我得到的响应是“ 200 ok”谁能告诉我这些代码缺少或缺少的内容。我会很感激的。提前非常感谢您。
正如我在评论中所说,我不确定为什么要经历ADO Stream的所有痛苦。据我从您的代码中得知,您所需要做的只是这样:
dim strFrom, strTo, strText, strDatetime
strFrom = request.querystring("from")
strTo = request.querystring("to")
strText = request.querystring("text")
strDatetime = request.querystring("datetime")
然后像现在一样使用FileSystemObject将这些值写入文件。
但是,如果您从第三方获得这些值,我希望至少对“ text”参数进行URL编码...