Delphi HTTP Site

I have to write a Delphi 5 program to send to a HTTP site 1 line of text to send SMS to selected numbers
e.g
'http://gateway.sitename.com.au/sendSMS?UserName=kevin&Password=test10&Recipient=0478111111&Message=This%20is%20a%20message&Sender=0438212142';

if I type it into the internet explorer it works fine
How do I do this in Delphi 5
KevinfeeningAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mahdi78Commented:
Put TWebBrowser and TButton component in form anddo this even

procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate('http://gateway.sitename.com.au/sendSMS?UserName=kevin&Password=test10&Recipient=0478111111&Message=This%20is%20a%20message&Sender=0438212142%27';
end;
0
Mahdi78Commented:
Sorry, this

procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate('http://gateway.sitename.com.au/sendSMS?UserName=kevin&Password=test10&Recipient=0478111111&Message=This%20is%20a%20message&Sender=0438212142');
end;
0
Mahdi78Commented:
I got it there is two method, this is one

PAS file

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, SHDocVw, StdCtrls;

type
  TForm1 = class(TForm)
    btSend: TButton;
    edUserName: TEdit;
    edRecipient: TEdit;
    mmMessage: TMemo;
    edSender: TEdit;
    edPassword: TEdit;
    edUrl: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    procedure btSendClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses IdURI, idhttp;

{$R *.dfm}

procedure TForm1.btSendClick(Sender: TObject);
var MySMS: string;
   idhttp: TIdHttp;
begin
idhttp := TIdhttp.Create(Owner);
  try
  MySMS := TIdURI.URLEncode(edUrl.Text+'?UserName='+edUserName.Text
  +'&Password='+edPassword.Text+'&Recipient='+edRecipient.Text
  +'&Message='+mmMessage.Text+'&Sender='+edSender.Text);
  idhttp.Get(MySMS);
  finally
  idhttp.Free;
  end;
end;

end.


DFM


object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 401
  ClientWidth = 276
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 24
    Top = 13
    Width = 49
    Height = 13
    Caption = 'UserName'
  end
  object Label2: TLabel
    Left = 24
    Top = 59
    Width = 46
    Height = 13
    Caption = 'Password'
  end
  object Label3: TLabel
    Left = 24
    Top = 104
    Width = 44
    Height = 13
    Caption = 'Recipient'
  end
  object Label4: TLabel
    Left = 24
    Top = 143
    Width = 34
    Height = 13
    Caption = 'Sender'
  end
  object Label5: TLabel
    Left = 24
    Top = 189
    Width = 19
    Height = 13
    Caption = 'URL'
  end
  object Label6: TLabel
    Left = 24
    Top = 235
    Width = 42
    Height = 13
    Caption = 'Message'
  end
  object btSend: TButton
    Left = 191
    Top = 368
    Width = 58
    Height = 25
    Caption = 'Send'
    TabOrder = 6
    OnClick = btSendClick
  end
  object edUserName: TEdit
    Left = 24
    Top = 32
    Width = 121
    Height = 21
    TabOrder = 0
    Text = 'kevin'
  end
  object edRecipient: TEdit
    Left = 24
    Top = 120
    Width = 121
    Height = 21
    TabOrder = 2
    Text = '0478111111'
  end
  object mmMessage: TMemo
    Left = 24
    Top = 254
    Width = 225
    Height = 89
    Lines.Strings = (
      'This is message')
    TabOrder = 5
  end
  object edSender: TEdit
    Left = 24
    Top = 162
    Width = 121
    Height = 21
    TabOrder = 3
    Text = '0438212142'
  end
  object edPassword: TEdit
    Left = 24
    Top = 77
    Width = 121
    Height = 21
    TabOrder = 1
    Text = 'test10'
  end
  object edUrl: TEdit
    Left = 24
    Top = 208
    Width = 225
    Height = 21
    TabOrder = 4
    Text = 'http://gateway.sitename.com.au/sendSMS'
  end
end




0
Mahdi78Commented:
Both method are in this example, the second is better

PAS file

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, SHDocVw, StdCtrls, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdHTTP;

type
  TForm1 = class(TForm)
    btSend: TButton;
    edUserName: TEdit;
    edRecipient: TEdit;
    mmMessage: TMemo;
    edSender: TEdit;
    edPassword: TEdit;
    edUrl: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    btSend2: TButton;
    IdHTTP1: TIdHTTP;
    procedure btSendClick(Sender: TObject);
    procedure btSend2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses IdURI, IdMultipartFormData;

{$R *.dfm}

procedure TForm1.btSendClick(Sender: TObject);
var MySMS: string;
   idhttp: TIdHttp;
begin
  MySMS := TIdURI.URLEncode(edUrl.Text+'?UserName='+edUserName.Text
  +'&Password='+edPassword.Text+'&Recipient='+edRecipient.Text
  +'&Message='+mmMessage.Text+'&Sender='+edSender.Text);
  idhttp1.Get(MySMS);
end;

procedure TForm1.btSend2Click(Sender: TObject);
var data: TIdMultiPartFormDataStream;
begin
data := TIdMultiPartFormDataStream.Create;
 try
  data.AddFormField('UserName', edUserName.Text);
  data.AddFormField('password', edPassword.Text);
  data.AddFormField('Recipient', edRecipient.Text);
  data.AddFormField('Message', mmMessage.Text);
  data.AddFormField('Sender', edSender.Text);
  IdHTTP1.Post(edUrl.Text, data);
 finally
 data.Free;
 end;

end;


end.



DFM file

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 401
  ClientWidth = 276
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 24
    Top = 13
    Width = 49
    Height = 13
    Caption = 'UserName'
  end
  object Label2: TLabel
    Left = 24
    Top = 59
    Width = 46
    Height = 13
    Caption = 'Password'
  end
  object Label3: TLabel
    Left = 24
    Top = 104
    Width = 44
    Height = 13
    Caption = 'Recipient'
  end
  object Label4: TLabel
    Left = 24
    Top = 143
    Width = 34
    Height = 13
    Caption = 'Sender'
  end
  object Label5: TLabel
    Left = 24
    Top = 189
    Width = 19
    Height = 13
    Caption = 'URL'
  end
  object Label6: TLabel
    Left = 24
    Top = 235
    Width = 42
    Height = 13
    Caption = 'Message'
  end
  object btSend: TButton
    Left = 119
    Top = 368
    Width = 58
    Height = 25
    Caption = 'Send'
    TabOrder = 6
    OnClick = btSendClick
  end
  object edUserName: TEdit
    Left = 24
    Top = 32
    Width = 121
    Height = 21
    TabOrder = 0
    Text = 'kevin'
  end
  object edRecipient: TEdit
    Left = 24
    Top = 120
    Width = 121
    Height = 21
    TabOrder = 2
    Text = '0478111111'
  end
  object mmMessage: TMemo
    Left = 24
    Top = 254
    Width = 225
    Height = 89
    Lines.Strings = (
      'This is message')
    TabOrder = 5
  end
  object edSender: TEdit
    Left = 24
    Top = 162
    Width = 121
    Height = 21
    TabOrder = 3
    Text = '0438212142'
  end
  object edPassword: TEdit
    Left = 24
    Top = 77
    Width = 121
    Height = 21
    TabOrder = 1
    Text = 'test10'
  end
  object edUrl: TEdit
    Left = 24
    Top = 208
    Width = 225
    Height = 21
    TabOrder = 4
    Text = 'http://gateway.sitename.com.au/sendSMS'
  end
  object btSend2: TButton
    Left = 183
    Top = 368
    Width = 57
    Height = 25
    Caption = 'Send2'
    TabOrder = 7
    OnClick = btSend2Click
  end
  object IdHTTP1: TIdHTTP
    AllowCookies = True
    ProxyParams.BasicAuthentication = False
    ProxyParams.ProxyPort = 0
    Request.ContentLength = -1
    Request.Accept = 'text/html, */*'
    Request.BasicAuthentication = False
    Request.UserAgent = 'Mozilla/3.0 (compatible; Indy Library)'
    HTTPOptions = [hoForceEncodeParams]
    Left = 208
    Top = 32
  end
end






0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KevinfeeningAuthor Commented:
The first Simple method works great thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.