Imports System.Reflection Imports Chilkat Public Class cPascom Dim API_USER_AUTHORIZATION = "bW9ieTpnWlhTSVprTnhmaUQxOEU=" Property Arbeitsplatz As String = "" Property Username As String = "" Dim TelUrl As String = "" Sub New() Dim ds As New DataSet cSQL.SQL2DS("SELECT Parameter FROM [Doku].[dbo].[TbL_Dienste] where name = 'TelefonanlageURL'", ds) If ds.Tables(0).Rows.Count > 0 Then TelUrl = ds.Tables(0).Rows(0).Item(0).ToString End If End Sub Public Function Anmelden() As Boolean If Arbeitsplatz.Length > 0 And Username.Length > 0 Then Try 'Benutzername: moby 'Passwort: XgDsFmMSutaMLA1 'BASIC Auth String: bW9ieTpYZ0RzRm1NU3V0YU1MQTE = cChilkat_Helper.UnlockCilkat() Dim API_STRING = TelUrl Dim rest As New Chilkat.Rest Dim success As Boolean Dim bTls As Boolean = True Dim port As Integer = 443 Dim bAutoReconnect As Boolean = True success = rest.Connect(API_STRING, port, bTls, bAutoReconnect) If (success <> True) Then Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason) Debug.WriteLine(rest.LastErrorText) Return False End If rest.AddHeader("Content-Type", "application/json") rest.SetAuthBasic("moby", "XgDsFmMSutaMLA1") Dim json As New Chilkat.JsonObject Dim successJsonLoad As Boolean = json.Load(" {""action"":""relocate"",""username"":""" & Username & """}}") If (successJsonLoad <> True) Then MsgBox(json.LastErrorText) Return False End If Dim sbRequestBody As New Chilkat.StringBuilder json.EmitSb(sbRequestBody) ' MsgBox(sbRequestBody.ToString) Dim sbResponseBody As New Chilkat.StringBuilder success = rest.FullRequestSb("POST", "/verag/services/location/" & Arbeitsplatz, sbRequestBody, sbResponseBody) If (success <> True) Then Debug.WriteLine(rest.LastErrorText) Return False End If Dim respStatusCode As Integer = rest.ResponseStatusCode If (respStatusCode <> 202) Then ' MsgBox(sbResponseBody.GetAsString()) Return False End If Dim jsonResp = New Chilkat.JsonObject() jsonResp.LoadSb(sbResponseBody) Dim gatewayId = jsonResp.StringOf("gatewayId") Dim Resp_error = jsonResp.StringOf("error") Dim Resp_errorCode = jsonResp.StringOf("errorCode") Return True Catch ex As Exception Return False End Try Return True Else Return False End If End Function Public Function Weiterleitung(fromNr As String, toNr As String, Optional ByRef Target As String = "") Try cChilkat_Helper.UnlockCilkat() Dim API_STRING = TelUrl Dim rest As New Chilkat.Rest Dim success As Boolean Dim bTls As Boolean = True Dim port As Integer = 443 Dim bAutoReconnect As Boolean = True success = rest.Connect(API_STRING, port, bTls, bAutoReconnect) If (success <> True) Then Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason) Debug.WriteLine(rest.LastErrorText) Return False End If rest.AddHeader("Content-Type", "application/json") rest.SetAuthBasic("moby", "XgDsFmMSutaMLA1") Dim json As New Chilkat.JsonObject Dim successJsonLoad As Boolean = json.Load(" {""target"":""" & toNr & """}}") If (successJsonLoad <> True) Then MsgBox(json.LastErrorText) Return False End If Dim sbRequestBody As New Chilkat.StringBuilder json.EmitSb(sbRequestBody) ' MsgBox(sbRequestBody.ToString) Dim sbResponseBody As New Chilkat.StringBuilder success = rest.FullRequestSb("POST", "/verag/services/redirect/" & fromNr, sbRequestBody, sbResponseBody) If (success <> True) Then Debug.WriteLine(rest.LastErrorText) Return False End If Dim respStatusCode As Integer = rest.ResponseStatusCode If (respStatusCode <> 200) Then ' MsgBox(sbResponseBody.GetAsString()) Return False End If Dim jsonResp = New Chilkat.JsonObject() jsonResp.LoadSb(sbResponseBody) Dim gatewayId = jsonResp.StringOf("gatewayId") Dim Resp_error = jsonResp.StringOf("error") Dim Resp_errorCode = jsonResp.StringOf("errorCode") Target = jsonResp.StringOf("target") ' MsgBox("Hier!!!") Return True Catch ex As Exception MsgBox(ex.Message) Return False End Try Return True End Function Function getredirect(ByRef target As String) As String Try cChilkat_Helper.UnlockCilkat() Dim API_STRING = TelUrl Dim rest As New Chilkat.Rest Dim success As Boolean Dim bTls As Boolean = True Dim port As Integer = 443 Dim bAutoReconnect As Boolean = True success = rest.Connect(API_STRING, port, bTls, bAutoReconnect) If (success <> True) Then Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason) Debug.WriteLine(rest.LastErrorText) Return False End If rest.AddHeader("Content-Type", "application/json") rest.SetAuthBasic("moby", "XgDsFmMSutaMLA1") Dim json As New Chilkat.JsonObject Dim sbRequestBody As New Chilkat.StringBuilder json.EmitSb(sbRequestBody) ' MsgBox(sbRequestBody.ToString) Dim sbResponseBody As New Chilkat.StringBuilder success = rest.FullRequestNoBodySb("GET", "/verag/services/redirect/", sbResponseBody) If (success <> True) Then Debug.WriteLine(rest.LastErrorText) Return False End If Dim respStatusCode As Integer = rest.ResponseStatusCode If (respStatusCode <> 200) Then Return False End If Return sbResponseBody.GetAfterBetween(target, ":", ",") Catch ex As Exception MsgBox(ex.Message) Return False End Try Return True End Function End Class