URL Not Returning Data Delphi Indy TIdHttp -
URL Not Returning Data Delphi Indy TIdHttp -
i trying access url in delphi using tidhttp indy tool. have done following:
set take cookies = true set handle redirect = true added tidcookiemanagerhttp://sms.saicomvoice.co.za:8900/saicom/index.php?action=login&username=some_username&password=some_password&login=login
the post request works , returns html. problem doesn't homecoming right html (see image below).
if take url ( filling in username , password ) , paste browser same delphi application logs right website. delphi app returns html login page.
the request supposed executed timeously in ttimer in delphi.
can lead me unto right path or point me in direction how can solve problem ?
some additional information
writestatus procedure writes output tlistboxbtnendpoll stops timer
procedure tfrmmain.tmrpolltimer(sender: tobject); var resulthtml: string; datatosend: tstringlist; begin inc(cycle, 1); lststatus.items.add(''); lststatus.items.add('=================='); writestatus('cycle : ' + inttostr(cycle)); lststatus.items.add('=================='); lststatus.items.add(''); datatosend := tstringlist.create; seek writestatus('setting request content type'); httprequest.request.contenttype := 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'; writestatus('setting request user agent'); httprequest.request.useragent := 'mozilla/5.0 (windows nt 5.1; rv:2.0b8) gecko/20100101 firefox/4.0b8'; writestatus('posting request'); resulthtml := httprequest.post(fposttourl, datatosend); writestatus('writing result'); flastresponse := resulthtml; writestatus('cycle : ' + inttostr(cycle) + ' -- finished'); lststatus.items.add(''); except on e: exception begin makenextentryerror := true; writestatus('an error occured: ' + e.message); if chkexceptionstop.checked begin btnendpoll.click; writestatus('stopping poll united nations expectedly!'); end; end; end; end;
* image illustration *
httprequest.request.contenttype := 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8';
that not valid contenttype
value. kind of value belongs in request.accept
property instead. tells server contenttypes client take in response.
resulthtml := httprequest.post(fposttourl, datatosend);
you posting blank tstringlist
. putting url browser's address bar sends get
request, not post
request, should using tidhttp.get()
instead:
resulthtml := httprequest.get('http://sms.saicomvoice.co.za:8900/saicom/index.php?action=login&username=some_username&password=some_password&login=login');
you utilize tidhttp.post()
if wanted simulate html webform beingness submitted server (since specifies method=post
), eg:
datatosend.add('username=some_username'); datatosend.add('password=some_password'); datatosend.add('login=login'); resulthtml := httprequest.post('http://sms.saicomvoice.co.za:8900/saicom/index.php?action=login', datatosend);
delphi indy idhttp
Comments
Post a Comment