PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 23 → Problem when trying to log on to a website
Problem when trying to log on to a website
Débuté par Paul White, 11 sep. 2018 10:09 - Aucune réponse
Posté le 11 septembre 2018 - 10:09
Hello everyone,

I'm trying desperately to log on to the following website but it does not work: http://www.drawinflation.com/user
Sending the form seems to work, but when I visit another page (http://www.drawinflation.com/user/3979), I always get the same "Forbidden" message.

The username and password are correct, they work when I enter them directly into the site, but via Windev it does not work. Here is my code below, if someone could tell me where the problem is, I would appreciate it a lot.

Thank you.

i, j are int
bExist is a boolean
bConnect is a boolean
bufResHttp is a Buffer
sform_build_id is a string
sCh1 is a string

HTTPRequest("http://www.drawinflation.com/user")
sCh1=HTTPGetResult(httpResult)
i=Position(sCh1,"form_build_id")
IF i>0 THEN
i=Position(sCh1,"=",i)+1
j=Position(sCh1,"/",i)
sform_build_id=StringDelete(NoSpace(Milieu(sCh1,i,j-i),sscAll),"""")
ELSE
Error("Impossible to login!")
RETURN
END

HTTPCreateForm("user-login")
HTTPAddParameter("user-login", "name", "****")
HTTPAddParameter("user-login", "pass", "****")
HTTPAddParameter("user-login", "form_build_id", sform_build_id)
HTTPAddParameter("user-login", "form_id", "user_login")
HTTPAddParameter("user-login", "op", "Log+in")
bExist=HTTPSendForm("user-login", "http://www.drawinflation.com/user",httpPost)

Multitask(-1)

IF bExist THEN
HTTPRequest("http://www.drawinflation.com/user/3979")
bufResHttp = HTTPGetResult(httpHeader)
IF Length(bufResHttp)>0 THEN
IF Position(bufResHttp,"Forbidden")=0 AND Position(bufResHttp,"ACCESS DENIED")=0 THEN
bConnect=True
END
END
END

IF bConnect=False THEN
Error("Unrecognized DI username or password!")
RETURN
END