【发布时间】:2023-10-23 10:20:01
【问题描述】:
提前谢谢你。谁能帮我解决这个问题, 我需要从回调 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”和“成本”。并将其保存到文本文件中。我对此一无所知。但我的“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”的响应 谁能告诉我这些代码缺少或缺少什么。 我会很感激的。非常感谢你。
【问题讨论】:
-
嗨,看起来你在这里采取了艰难的方式......首先你应该确保你的“文本”和“日期时间”参数是 URL 编码的。之后,只需使用 request.querystring() 检索这些参数并使用 FileSystemObject 将它们写入文件即可。我认为不需要 ADO 流...
-
您好@ChrisBE,我很抱歉,请您详细解释一下。因为老实说我不明白。
标签: json https asp-classic webservice-client getresponse