我尝试使用Twilio发送短信。我发现了一篇文章(https://www.twilio.com/blog/2010/04/using-twilio-with-classic-asp-and-vbscript.html),它展示了如何通过VBScript执行此操作,但我想知道如何在从客户端计算机而不是服务器发送POST请求时修改脚本。
我试图给这个第一遍,但我对VBScript不太熟悉。我发现一些文章说使用System.Web.HttpUtility来运行URLEncode()
非常感谢任何帮助。
def line_item_params
# just to raise ActionController::ParameterMissing if key is missing
params.require(:line_items)
# this is the actual whitelist
params.permit(line_items: [:quantity, :price, :menu_item_id])
end
答案 0 :(得分:2)
由于VBScript没有本机功能,您必须创建自己的功能或找到另一种解决方法(就像一个可以为您完成的COM库)。
过去,我使用过此代码(最初取自this gist,其灵感来自VBA solution on StackOverflow)。< / p>
' Encode special characters of a string
' this is useful when you want to put a string in the URL
' inspired by https://stackoverflow.com/questions/218181/how-can-i-url-encode-a-string-in-excel-vba
Public Function URLEncode( StringVal )
Dim i, CharCode, Char, Space
Dim StringLen
StringLen = Len(StringVal)
ReDim result(StringLen)
Space = "+"
'Space = "%20"
For i = 1 To StringLen
Char = Mid(StringVal, i, 1)
CharCode = AscW(Char)
If 97 <= CharCode And CharCode <= 122 _
Or 64 <= CharCode And CharCode <= 90 _
Or 48 <= CharCode And CharCode <= 57 _
Or 45 = CharCode _
Or 46 = CharCode _
Or 95 = CharCode _
Or 126 = CharCode Then
result(i) = Char
ElseIf 32 = CharCode Then
result(i) = Space
Else
result(i) = "&#" & CharCode & ";"
End If
Next
URLEncode = Join(result, "")
End Function