Okay hi and good evening ,
Earlier on I was on Mobile so chances of coming on the computer was limited, hence i decided to come online and write on here as i have the time here.
Now am trying to simulate a simple HTTP Request with Wininet i wanted to be sure of what I am Doing hence i decided to come up with a source code , I didnt fill other parameters because i wanted to see how it would be placed when Simulating(Sincerely pardon me as this is my first time Handling something like this)
Code goes like this
program Project1;
{$mode delphi}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes , Wininet , Windows
{ you can add units after this };
procedure PostData()
var
hInet: HINTERNET;
hHTTP: HINTERNET;
hReq: HINTERNET;
const
accept: packed array[0..1] of LPWSTR = (PChar('*/*'), nil);
header: string = 'Content-Type: application/x-www-form-urlencoded';
begin
hInet := InternetOpen(PChar(UserAgent), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
hHTTP := InternetConnect(hInet, PChar(Server), INTERNET_DEFAULT_HTTP_PORT, nil, nil, INTERNET_SERVICE_HTTP, 0, 1);
hReq := HttpOpenRequest(hHTTP, PChar('POST'), PChar(Resource), nil, nil, @accept, 0, 1);
if not HttpSendRequest(hReq, PChar(header), length(header), PChar(Data), length(Data)) then
raise Exception.Create('HttpOpenRequest failed. ' + SysErrorMessage(GetLastError));
InternetCloseHandle(hReq);
InternetCloseHandle(hHTTP);
InternetCloseHandle(hInet);
end
begin
end.
Now In the case of the parameters i used Live HTTP Headers to retrieve the headers as well so i got this
https://perfectmoney.is/api/step1.asp
POST /api/step1.asp HTTP/1.1
Host: perfectmoney.is
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://perfectmoney.is/api/pay.asp?acc=&cur=&name=&email=&memo=&pid=&ref=https%3A%2F%2Fperfectmoney.is&amount=250&action=Make+payment
Cookie: details=1366x768; data=289775471; pmc=b76ede0e957fd5ca7e6b03beb9949234; PM_SESSION=9e58e6742c8adebcb8c1ab00a2026e7603ed02108b9858797427819ce93efe91d4fa0a74
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 257
PAYEE_ACCOUNT=&PAYEE_NAME=&PAYMENT_UNITS=&STATUS_URL=mailto%3A&PAYMENT_URL=https%253A%252F%252Fperfectmoney.is&PAYMENT_URL_METHOD=LINK&NOPAYMENT_URL=https%253A%252F%252Fperfectmoney.is&NOPAYMENT_URL_METHOD=LINK&SUGGESTED_MEMO=&PAYMENT_ID=&PAYMENT_AMOUNT=250
Now Good sir, How do I place the Values and do this in Pascal? suppose this was C / C++ I could have tried something , but i really would like to do this in Pascal, kindly help.
Help would be much much appreciated
