login about faq

this is my code:

Public Sub Command1_Click() Dim success As Long Set http = ChilkatHttp1 ' Any string unlocks the component for the 1st 30 days. success = http.UnlockComponent("trial") If (success <> 1) Then Text1.Text = Text1.Text & http.LastErrorText & vbCrLf Exit Sub End If

http.AcceptCharset = "" http.UserAgent = "" http.AcceptLanguage = ""

http.AllowGzip = 0

http.AddQuickHeader "LOLCOOKIE: ", Chr(34) & "m6RRxhWgO0EpzT0YsRBjKbICa6fnGTME/gfnR7QyP0IwaYCJtU45ADwbfMCNPMXdhX7o0tmJTYzTbDJ7WMXcJA""; JSESSIONID: 2CFF7ED1DB0E02D7DCF906D82B566EDF"""

Dim jsonText As String

jsonText = "{""anno"":2013,""mese"":5,""giorno"":2,""progressivoGiornaliero"":1}"

Dim resp As ChilkatHttpResponse

Set resp = http.PostJson("HTTPS://vetrina.giocodellotto.it/serviziFE/10elotto/raccoltaFrequente.json", jsonText) If (resp Is Nothing) Then Text1.Text = Text1.Text & http.LastErrorText & vbCrLf Else ' Display the JSON response. Text1.Text = Text1.Text & resp.bodyStr & vbCrLf

End If End Sub

I can't send and receive data! Please can someone look at this code and tell me where is the error? This is the website link: https://www.lottomatica.it/lotto-online/gioca/schedina-10-e-lotto.html Thanks in advance!

asked May 05 '13 at 06:08

STEP's gravatar image

STEP
1111


This gets an HTTP 200 response (OK) from the server for me, although the body is empty. Maybe a problem with your LOLCOOKIE, JSESSIONID, or JSON string parameters?

Public Sub Command1_Click()
   Dim jsonText As String
   Dim http As CHILKATHTTPLib.ChilkatHttp
   Dim resp As ChilkatHttpResponse

Set http = New CHILKATHTTPLib.ChilkatHttp

If http.UnlockComponent("trial") <> 1 Then
      Debug.Print "Unlock Err: " & http.LastErrorText
      Exit Sub
   End If

http.SetRequestHeader "LOLCOOKIE", "m6RRxhWgO0EpzT0YsRBjKbICa6fnGTME/gfnR7QyP0IwaYCJtU45ADwbfMCNPMXdhX7o0tmJTYzTbDJ7WMXcJA"
   http.SetRequestHeader "JSESSIONID", "2CFF7ED1DB0E02D7DCF906D82B566EDF"

jsonText = "{""anno"":2013,""mese"":5,""giorno"":2,""progressivoGiornaliero"":1}"

Set resp = http.PostJson("HTTPS://vetrina.giocodellotto.it/serviziFE/10elotto/raccoltaFrequente.json", jsonText)

If (resp Is Nothing) Then
      Debug.Assert False
      Debug.Print "Request Err: " & http.LastErrorText

Else   ' Display the JSON response.
      If resp.StatusCode = 200 Then   ' OK
         Debug.Print "Received response: " & resp.bodyStr

Else
         Debug.Print "Response Err: " & resp.LastErrorText

End If

End If
End Sub
link

answered May 06 '13 at 09:03

jpbro's gravatar image

jpbro ♦
1.1k2618

edited May 06 '13 at 09:03

Thanks for answer! I tried to change the values ​​you suggested but the answer is always empty!! This is the data request to server and the response:

URL richiesta:

https://vetrina.giocodellotto.it/serviziFE/10elotto/raccoltaFrequente.json

Metodo di richiesta:

POST

Codice di stato:

HTTP/1.1 200 OK

Header della richiesta

X-Requested-With:XMLHttpRequestUser-Agent:Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0

Referer:https://vetrina.giocodellotto.it/vetrinaDieciELotto/interne/estrazioni-precedenti.html

Pragma:no-cache

Host:vetrina.giocodellotto.it

Content-Type:application/json; charset=UTF-8

Content-Length:62

Connection:keep-alive

Cache-Control:no-cache

Accept-Language:it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3

Accept-Encoding:gzip, deflate

Accept:application/json, text/javascript, /; q=0.01

Cookie inviato LOLCOOKIE:"m6RRxhWgO0EpzT0YsRBjKbICa6fnGTME/gfnR7QyP0IwaYCJtU45ADwbfMCNPMXdhX7o0tmJTYzTbDJ7WMXcJA

JSESSIONID:83D4F16F15AB3B5B02748F9C4B1FF83E

checkCookie:checkCookie

Corpo della richiesta

{"anno":2013,"mese":5,"giorno":7,"progressivoGiornaliero":"1"}

Header della risposta

Server:Apache

Keep-Alive:timeout=5, max=99

Date:Tue, 07 May 2013 08:28:01 GMT

Content-Type:application/json;charset=UTF-8

Content-Length:213

Connection:Keep-Alive

Corpo della risposta

{"esito":"OK","messaggio":null,"dataRaccolta":1367877600000,"progressivoGiornaliero":1,"numeri":[12,88,41,30,37,74,46,13,42,60,56,80,35,20,51,7,85,76,24,26],"identificativoVtis":273671,"statoRaccolta":"CALCOLATA"}

I have log this data from firefox but I haven't idea because i don't see the response on resp.bodyStr Please help me!

link

answered May 07 '13 at 04:52

STEP's gravatar image

STEP
1111

One thing I notice is that Chilkat produces a Content-Type header of application/jsonrequest and an Accept header of the same, whereas Firefox produces application/json. Maybe this is also having an effect? I don't know enough about JSON queries to know if this would be an issue or not.

Also, is there any API documentation for the website? How do I get a valid LOLCOOKIE and JSESSIONID for testing?

Lastly, I don't know Italian, so I can't be sure, but it looks like the LOLCOOKIE and JSESSIONID are actually cookies, not some kind of custom header. In that case, the following code might work (assuming your LOLCOOKIE and JSESSIONID values are valid):

Public Sub Command1_Click()
   Dim jsonText As String
   Dim http As CHILKATHTTPLib.ChilkatHttp
   Dim resp As ChilkatHttpResponse

Set http = New CHILKATHTTPLib.ChilkatHttp

If http.UnlockComponent("trial") <> 1 Then
      Debug.Print "Unlock Err: " & http.LastErrorText
      Exit Sub
   End If

http.SetRequestHeader "COOKIE", "LOLCOOKIE=m6RRxhWgO0EpzT0YsRBjKbICa6fnGTME/gfnR7QyP0IwaYCJtU45ADwbfMCNPMXdhX7o0tmJTYzTbDJ7WMXcJA; JSESSIONID=2CFF7ED1DB0E02D7DCF906D82B566EDF;"

jsonText = "{""anno"":2013,""mese"":5,""giorno"":2,""progressivoGiornaliero"":1}"

Set resp = http.PostJson("HTTPS://vetrina.giocodellotto.it/serviziFE/10elotto/raccoltaFrequente.json", jsonText)

If (resp Is Nothing) Then
      Debug.Assert False
      Debug.Print "Request Err: " & http.LastErrorText

Else   ' Display the JSON response.
      If resp.StatusCode = 200 Then   ' OK
         Debug.Print "Received response: " & resp.bodyStr

Else
         Debug.Print "Response Err: " & resp.bodyStr

End If

End If
End Sub
link

answered May 08 '13 at 08:59

jpbro's gravatar image

jpbro ♦
1.1k2618

edited May 08 '13 at 08:59

The v9.4.1 release, when available, will continue to use "application/jsonrequest". If a server requires the content-type to be "application/json", then the Chilkat.Http.SynchronousRequest method should instead be used to allow for the full control of the Content-Type and Accept request headers. The PostJson method is a convenience method designed to make it easy to send JSON requests to properly implemented servers.

link

answered May 08 '13 at 11:59

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

edited May 08 '13 at 12:17

A very cursory Google search leads me to believe that application/jsonrequest is to spec, but many servers only handle application/json - maybe we need an option to handle either case, or maybe Accept: application/json, application/jsonrequest is optimal?

link

answered May 08 '13 at 12:04

jpbro's gravatar image

jpbro ♦
1.1k2618

I reverted the proposed change. See the comment above..

(May 08 '13 at 12:18) chilkat ♦♦

First,Thanks to all! Second, today the server is down because not send LOLCOOKIE to remote pc and if i send querying to server, the response is 500 because the lol cookie not found! My suspect is that the software not working because they are updating server See you ASAP!!! P.S. Sorry for my bad English!!

(May 09 '13 at 04:18) STEP
 Hi there!! I added an addon for firefox called HttpRequester, and I saw that 
setting the request headers only cookies, the server responded with status 200 but 
no response data, so I added the string 
"Referer", "https://vetrina.giocodellotto.it/vetrinaDieciELotto/interne/estrazioni-precedenti.html"
  and the only way I got in response to the data required!! I tried adding the 
string "Referer" to my VB6 code and the answer is a server error

This is the code and response:

Public Sub Command3_Click()
   Dim jsonText As String
   Dim http As CHILKATHTTPLib.ChilkatHttp
   Dim resp As ChilkatHttpResponse
Set http = New CHILKATHTTPLib.ChilkatHttp

If http.UnlockComponent("trial") <> 1 Then
      Debug.Print "Unlock Err: " & http.LastErrorText
      Exit Sub
   End If

http.AcceptCharset = ""
http.UserAgent = ""
http.AcceptLanguage = ""
http.AllowGzip = 0

jsonText = "{""anno"":2013,""mese"":5,""giorno"":11,""progressivoGiornaliero"":120}"

http.AddQuickHeader "Referer", "https://vetrina.giocodellotto.it/vetrinaDieciELotto/interne/estrazioni-precedenti.html"
http.AddQuickHeader "Cookie", "LOLCOOKIE=m6RRxhWgO0EpzT0YsRBjKbICa6fnGTME/gfnR7QyP0IwaYCJtU45ADwbfMCNPMXdhX7o0tmJTYzTbDJ7WMXcJA== ; JSESSIONID=56D52D4E6DD44DADC40FAA9BE1272EE1"

Set resp = http.PostJson("HTTPS://vetrina.giocodellotto.it/serviziFE/10elotto/raccoltaFrequente.json", jsonText)

If (resp Is Nothing) Then
      Debug.Assert False
      Debug.Print "Request Err: " & http.LastErrorText

Else   ' Display the JSON response.
      If resp.StatusCode = 200 Then   ' OK
         Debug.Print "Received response: " & resp.bodyStr

Else
         Text1.Text = "Response Err: " & resp.LastErrorText & resp.StatusCode & resp.bodyStr
End If
End If

**If add to http.AddQuickHeader the referer string, i have 
statuscode 500 and see this error:**

HTTP Status 500 - 

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.bouncycastle.crypto.DataLengthException: last block incomplete in 
decryption
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

org.bouncycastle.crypto.DataLengthException: last block incomplete in decryption
    org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher.doFinal(Unknown Source)
    it.lottomatica.lol.services.util.Encryptor.callCipher(Encryptor.java:34)
    it.lottomatica.lol.services.util.Encryptor.decrypt(Encryptor.java:68)
    it.lottomatica.lol.services.util.Encryptor.decryptString(Encryptor.java:76)
    it.lottomatica.lol.services.CookieServices.getUserFromRequest(CookieServices.java:28)
    it.lottomatica.lol.interceptor.ServiziFEInteceptor.caricaUtenteDaCookieLOL(ServiziFEInteceptor.java:44)
    it.lottomatica.lol.interceptor.ServiziFEInteceptor.preHandle(ServiziFEInteceptor.java:32)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:914)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs.


Apache Tomcat/6.0.32

</body></html>

Thanks in advance to everyone who wants to help me!!

link

answered May 11 '13 at 04:51

STEP's gravatar image

STEP
1111

Hi. I also have the same problem. the json is empty. Can you tell me how you solved it? thanks

link

answered Feb 01 '14 at 02:28

Appy's gravatar image

Appy
1

Help Meeeeeeeee!!!!!!!!!!!!!!!

(Feb 02 '14 at 17:54) Appy
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×35

Asked: May 05 '13 at 06:08

Seen: 6,260 times

Last updated: Feb 02 '14 at 17:54

powered by OSQA