I have a Delphi XE6 application which I would like to install on an Android phone. I am testing it on a Windows platform. Below is my unit source code. On my form I have a button, idHttp Indy tool and a Memo Field.
The problem is that when I click the button I get the error
HTTP/1.1 403 Forbidden.
But I can access the site through my browser, so the page isn't forbidden. Can anyone see a problem?
I have searched for how to do post requests using firemonkey and delphi and I found these links:
- How to send a HTTP Post Request in Delphi 2010 using WinInet
- POST request in Delphi XE
- How are parameters sent in an HTTP POST request?
None of which help me.
unit Start_Interface_u;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes,
System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,
FMX.Layouts, FMX.Memo;
type
TForm1 = class(TForm)
btnLogin: TButton;
IdHTTP1: TIdHTTP;
Memo1: TMemo;
procedure btnLoginClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.btnLoginClick(Sender: TObject);
Var
sResult: String;
DataToSend :TStringList;
begin
DataToSend := TStringList.Create;
//DataToSend.Add('login_email=some_email');
//DataToSend.Add('login_pass=some_password');
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
Memo1.Lines.Add(idHTTP1.Post('http://mysite.co.za/dash.php', DataToSend));
end;
end.