Recent

Author Topic: [SOLVED] Is my syntax correct when using this function?  (Read 379 times)

Matt723

  • New Member
  • *
  • Posts: 20
[SOLVED] Is my syntax correct when using this function?
« on: December 15, 2019, 10:12:21 am »
I am trying to login to this website (view-source:http://www.tigerfan.com/login) using my application. I am using the httpRequest and process functions from the simpleinternet unit to acheive this. This is my code:

   
Code: Pascal  [Select][+][-]
  1. uses simpleinternet;
  2.     procedure TForm1.Button1Click(Sender: TObject);
  3.     begin
  4.       httpRequest(process('http://www.tigerfan.com/login', 'form(pageLogin, {"login": "aaaExample1", "password": "Example1"})'));
  5.     end;  

The account details above are real and working, if anyone wants to try it.

This code is not working and I get no errors or exceptions, just this warning (which I'm ignoring):

Code: Pascal  [Select][+][-]
  1. unit1.pas(36,3) Warning: Symbol "httpRequest" is deprecated: "Use destination.retrieve() instead."

I know that the `httpRequest` function works because the following test code has output:

Code: Pascal  [Select][+][-]
  1. edit1.text := (httpRequest('http://www.google.com'));

Is it possible that the syntax of the parameters is wrong? If you have any suggestions as to why this code isn't working, all are very much appreciated.
« Last Edit: December 15, 2019, 02:46:58 pm by Matt723 »

BeniBela

  • Hero Member
  • *****
  • Posts: 753
    • homepage
Re: Is my syntax correct when using this function?
« Reply #1 on: December 15, 2019, 02:39:02 pm »
You need to which  form  it fills out with an xpath expression, i.e.:

   
Code: Pascal  [Select][+][-]
  1. uses simpleinternet;
  2.     procedure TForm1.Button1Click(Sender: TObject);
  3.     begin
  4.       httpRequest(process('http://www.tigerfan.com/login', 'form(//form[@id = "pageLogin"], {"login": "aaaExample1", "password": "Example1"})'));
  5.     end;  

Matt723

  • New Member
  • *
  • Posts: 20
Re: Is my syntax correct when using this function?
« Reply #2 on: December 15, 2019, 02:46:25 pm »
You need to which  form  it fills out with an xpath expression, i.e.:

   
Code: Pascal  [Select][+][-]
  1. uses simpleinternet;
  2.     procedure TForm1.Button1Click(Sender: TObject);
  3.     begin
  4.       httpRequest(process('http://www.tigerfan.com/login', 'form(//form[@id = "pageLogin"], {"login": "aaaExample1", "password": "Example1"})'));
  5.     end;  
Thanks you very much BeniBela, that's working perfectly now. Part of the reason for my confusion was the "//form" that I saw in some of your older posts too - I thought that was a comment and I was supposed to replace it with the form name. Thanks so much for your help!

BeniBela

  • Hero Member
  • *****
  • Posts: 753
    • homepage
Re: [SOLVED] Is my syntax correct when using this function?
« Reply #3 on: December 15, 2019, 02:53:31 pm »
I usually use //form when there is only one form on the page.

 

TinyPortal © 2005-2018