Sub Test
soo.InitializeSSL("Socket1",Null,"")
soo.Connect("sandbox.letterxpress.de",443,1000)
End Sub
Sub Socket1_Connected(Successful As Boolean)
Log(Successful)
Dim Request As Map
Request.Initialize
Request.Put("auth",CreateMap("apikey":"KEY","username":"NAME"))
Request.Put("letter",CreateMap("specification":CreateMap("page":"1","color":"1","mode":"simplex","ship":"national")))
Dim J As JSONGenerator
J.Initialize(Request)
Dim json As String
json = J.ToPrettyString(4)
Dim send As String
send = "GET /v1/getPrice HTTP/1.1" & Chr(13) & Chr(10)
send = send & "Host: sandbox.letterxpress.de" & Chr(13) & Chr(10)
send = send & "Content-Length: " & json.Length & Chr(13) & Chr(10)
send = send & "Connection: keep-alive" & Chr(13) & Chr(10)
send = send & "Content-Type: application/json" & Chr(13) & Chr(10)
send = send & "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)" & Chr(13) & Chr(10)
send = send & Chr(13) & Chr(10)
send = send & Chr(13) & Chr(10)
send = send & json
Log(send)
Dim out As OutputStream = soo.OutputStream
Dim buffer() As Byte
buffer = send.GetBytes("UTF8")
out.WriteBytes(buffer,0,buffer.Length)
out.Flush
'out.Close
Dim inp As InputStream = soo.InputStream
Dim buffer(1024) As Byte
If inp.IsInitialized=True Then Log("Jo")
Dim count As Int
Dim rec As String =""
Dim exitcondition As Boolean
exitcondition=False
Do Until exitcondition
'Header + Content-Length
Log("Wait")
Log("Connected " & soo.Connected)
Sleep(1000)
Log("BytesAvailable " & inp.BytesAvailable)
'If inp.BytesAvailable > 0 Then
Log("input")
count = inp.ReadBytes(buffer, 0, buffer.length)
If count>0 Then
rec = BytesToString(buffer,0,count,"UTF-8")
Log(rec)
End If
'End If
Loop
Log("End")
End Sub