PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → JSON - code in WinDev ?
JSON - code in WinDev ?
Iniciado por santtu55, 10,nov. 2014 10:57 - 10 respuestas
Publicado el 10,noviembre 2014 - 10:57
Hi, I have used windev since 1998 , first version is 4.1 and now I use 17. And in the future I upgrade it to 20.

But question is that have some acknowledge about JSON and Windev ?

Can I make JSON call by Windev or must I use WebDev ?

In thise adress there is exampl code made by python:
https://github.com/VeikkausOy/sport-games-robot

How can I make this by Windev:

----------------------------------------------
# subject structure that must be
headers = {
'Content-type':'application/json',
'Accept':'application/json',
'X-ESA-API-Key':'ROBOT'
}

# Login to Veikkaus.fi site, return session-object
def login (username, password):
s = requests.Session()
login_req = {"type":"STANDARD_LOGIN","login":username,"password":password}
r = s.post("https://www.veikkaus.fi/api/v1/sessions", data=json.dumps(login_req), headers=headers)
if r.status_code == 200:
return s
else:
raise Exception("Authentication failed", r.status_code)

# Main funktio.
# 1. Login
# 2. Get 'Moniveto' targets ( when logged person ) ( 'Moniveto' is betting system in Veikkaus )
# 3. Prints answer
def main():
s = login('esimerkki','salasana')
r = s.get('https://www.veikkaus.fi/api/v1/sport-games/draws…', headers=headers)
print r.text

------------------------------------------------------

Best regards

Lasse Sandström

user in Finland
Publicado el 10,noviembre 2014 - 16:05
Hi, again, can I use HTTPRequest to do this:

HTTPRequest( ...
"https://www.veikkaus.fi/", ...
"", ...
"Content-type:application/json,Accept:application/json,X-ESA-API-Key:ROBOT", ...
"api/v1/sport-games/draws?game-names=MULTISCORE", ...
"application/json" )

or how this parameters must be assigned ? As Also login must do before this, and login only one time ???

br Lasse S
Publicado el 11,noviembre 2014 - 08:42
I would love to know as well
Publicado el 11,noviembre 2014 - 11:55
Hi Lasse

JSON is only a text formatting set of rules, like XML. It has nothing
to do with the communication mechanism.

So yes, you can do JSON in windev, as there are many string
manipulations functions that will allow you to manage all that.

As for the httprequest question, you can probably do what you want, but
without the full specs of the webservice you are trying to reach, its
impossible to tell you in details how.

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXReplication, your open source replication system is available on
my web site!!!
WXShowroom.com: Show your projects!
More information on http://www.fabriceharari.com


On 11/10/2014 9:05 AM, "Lasse Sandström" wrote:
Hi, again, can I use HTTPRequest to do this:

HTTPRequest( ...
"https://www.veikkaus.fi/", ...
"", ...
"Content-type:application/json,Accept:application/json,X-ESA-API-Key:ROBOT", ...
"api/v1/sport-games/draws?game-names=MULTISCORE", ...
"application/json" )

or how this parameters must be assigned ? As Also login must do before
this, and login only one time ???

br Lasse S
Publicado el 11,noviembre 2014 - 12:14
Full details , and examples is shown in "https://github.com/VeikkausOy/sport-games-robot" but these examples
are in Python , this is not knonw for me.

SO, What im trying to do is get data form 'Veikkaus.fi' with JSON, this is their new communication method, as old is mobile format which was full text format.

So I'm going to log in with JSON and get data there.

This is something like betting and manipulating row that can be played.

So it's difficult.

best regards,

Lasse Sandström
Publicado el 11,noviembre 2014 - 13:59
Hi,

I don't know where my answer is gone, but here is it again.

I am trying to get data/info about betting objects in 'Veikkaus.fi' site as it's new contacting method is 'JSON'. Old one ends end of this year.

JSON examples is show in https://github.com/VeikkausOy/sport-games-robot - site but unfortunately by Python, not known to me at all.

Betting object like 'MULTISCORE' and 'SPORT'.

First my program must login , then get this MULTISCORE or SPORT object that it available in time.

Then analyze this and play all the bets that is goodone this is done before. But this new system I don't get this MULTISCORE and SPORT - object that is available.

So question is again and I need some help about this HTTPRequest as it's not exactly in helpfile or ( I'm stupid and can't understand it , also possible ).

best regards,

Lasse Sandström
Publicado el 11,noviembre 2014 - 15:14
Hi, Veikkaus use REST-interface fron JSON.

If this information needed before answering ?
Publicado el 11,noviembre 2014 - 20:12
Hi Lasse

REST is the communication protocol
JSON is the format of the text file that is sent using this
communication protocol

REST is done with httprequest, JSON with string functions

After that, the details is in the API documentation, examples are
something that you'll need AFTER READING the doc

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXReplication, your open source replication system is available on
my web site!!!
WXShowroom.com: Show your projects!
More information on http://www.fabriceharari.com


On 11/11/2014 9:14 AM, "Lasse Sandström" wrote:
Hi, Veikkaus use REST-interface fron JSON.

If this information needed before answering ?
Publicado el 11,noviembre 2014 - 23:36
All searc must accept cookies!

This search draw results from Veikkaus.fi:

$ curl --compressed \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'X-ESA-API-Key: ROBOT' \
'https://www.veikkaus.fi/api/v1/sport-games/draws…'


So, how can this be done with Windev : HTTPRequest

And barrier layer schema from Veikkaus.fi:

Login request

POST /api/v1/players/self/session

Data for login:

{"type":"STANDARD_LOGIN","login":"example","password":"password"}


And answer is in JSON format which includes customers data


examp with cURL:


$ curl --compressed \
-X POST \
-d '{"type":"STANDARD_LOGIN","login":"example","password":"password"}' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'X-ESA-API-Key: ROBOT' \
'https://www.veikkaus.fi/api/v1/sessions'


Gametarget
request

GET /api/v1/sport-games/draws

parameters

?game-names=SPORT

or

?game-names=MULTISCORE

and answer:

doc/sport-draws-reply.json


exampl. with cURL

$ curl --compressed \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'X-ESA-API-Key: ROBOT' \
'https://www.veikkaus.fi/api/v1/sport-games/draws…'


Next section is how to send games to 'Veikkaus.fi' ( play in )

POST /api/v1/sport-games/wagers

Data for this:

doc/multiscore-wager-request.json
or
doc/sport-wager-request.json


etc.

So how does these work with HTTPRequest ??


Is this info enough to tell or someone to tell how this can be done in WINDEV.

My email: santtu55 (at) ren.to
Publicado el 13,noviembre 2014 - 21:29
Hi, ok

I have now tried several ways and I think that this is impossbile to do with Windev.

So I forget this.
Publicado el 09,marzo 2015 - 12:00
vous pouvez utiliser ce code par exemple
SI HTTPRequête("http://api.openweathermap.org/data/2.5/forecast…") = Vrai ALORS
Info("Requête OK, résultat :", ...
HTMLVersTexte(HTTPDonneRésultat(httpRésultat)))
SINON
Erreur(ErreurInfo())
FIN
et manipuler le texte obtenu par programmation en fonction de ce que tu veut.