Sub SendReplyNexmo(reply As String)
Dim w As New Net.WebClient
Dim values As New Specialized.NameValueCollection
values.Add("to", sender)
values.Add("text", reply)
values.Add("from", sentto)
values.Add("api_key", nexAPIKey)
values.Add("api_secret", nexAPISecret)
Try
w.UploadValues(New Uri("https://rest.nexmo.com/sms/json"), "POST", values)
w.Dispose()
Catch ex As Exception
Dim logFile As IO.StreamWriter
If IsNothing(HttpContext.Current) Then
logFile = New IO.StreamWriter("C:\logs\SMSerror.log", True)
Else
logFile = New IO.StreamWriter(HttpContext.Current.Server.MapPath("/logs/SMSerror.log"), True)
End If
logFile.WriteLine(ex.Message)
logFile.Dispose()
End Try
End Sub
这是我用于连接Nexmo API的代码。然后,我的应用程序无处中断了,现在我得到了错误。
基础连接已关闭:发送中发生意外错误。
我尝试设置自定义的用户代理字符串,未做任何更改。我尝试搜索文档。
Windows Server 2008 R2上的ASP.NET 4.6.1 IIS 7.5。桌面版本可在Windows 7上运行