I am trying to access a URL in Delphi using a TIdHTTP Indy Tool. I have done the following:
- Set Accept Cookies = True
- Set Handle Redirect = True
- Added a TIdCookieManager
http://sms.saicomvoice.co.za:8900/saicom/index.php?action=login&username=SOME_USERNAME&password=SOME_PASSWORD&login=login
The Post request works and it returns the HTML. The problem is it doesn't return the correct HTML (See Image Below).
If I take that URL ( Filling in the username and password ) and paste it into my browser exactly The Same as my Delphi Application would then logs into the correct website. But as soon as I do it with my Delphi App it returns the HTML for the login page.
The request is supposed to be executed timeously in a TTimer in Delphi.
Can anyone lead me unto the right path or point me in a direction as to how I can solve this problem ?
Some Additional Information
- WriteStatus is a Procedure That writes output to a TListBox
BtnEndPoll Stops the 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; Try 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 Do Begin MakeNextEntryError := True; WriteStatus('An Error Occured: ' + E.Message); If ChkExceptionStop.Checked Then Begin BtnEndPoll.Click; WriteStatus('Stopping Poll Un Expectedly!'); End; End; End; End;
* Image Example *