Compare the Market: Nobody’s lower priced for quality SMS Lowest Bulk SMS Prices Free Bulk SMS Software
text marketer reviews Text Marketer RSS feeds

Example of a Delphi/Pascal Interface for the Bulk SMS Gateway / API

Posted on February 11th, 2010 by admin.


Categories: Technical

For more information regarding the bulk sending API click here.

A code example for sending SMS via a Delphi Pascal language, thanks to Graham Murt for the example code.

{*******************************************************************************
*                                                                              *
*                 TextMarketer Delphi/Pascal Interface                         *
*                                                                              *
********************************************************************************

{

  example use:

  procedure TForm1.Button1Click(Sender: TObject);
  begin
    SendTextMarketerSms(username, password, sender, recipient, message);
  end;

}

unit untTextMarketer;

interface

uses Classes, IdHttp;

const
  C_HTTP_URL  = 'http://www.textmarketer.biz/gateway/';

type
  TTextMarketerSMS = class
  private
    FHttp: TIdHttp;
    FPassword: string;
    FUsername: string;
  public
    constructor Create; virtual;
    destructor Destroy; override;
    function SendSms(AOriginator,
                     ANumber,
                     AMessage: string;
                     AXmlResponse: Boolean): string;
    property Username: string read FUsername write FUsername;
    property Password: string read FPassword write FPassword;
  end;

  function SendTextMarketerSms(AUsername, APassword, ASender, ANumber, AMessage: string): string;

implementation

uses SysUtils;

function SendTextMarketerSms(AUsername, APassword, ASender, ANumber, AMessage: string): string;
var
  ASms: TTextMarketerSMS;
begin
  ASms := TTextMarketerSMS.Create;
  try
    ASms.Username := AUsername;
    ASms.Password := APassword;
    Result := ASms.SendSms(ASender, ANumber, AMessage, True);
  finally
    ASms.Free;
  end;
end;

{ TTextMarketerSMS }

function UrlEncode(const DecodedStr: String): String;
var
  I: Integer;
begin
  Result := '';
  if Length(DecodedStr) > 0 then
    for I := 1 to Length(DecodedStr) do
    begin
      if not (DecodedStr[I] in ['0'..'9', 'a'..'z',
                                       'A'..'Z', ' ']) then
        if DecodedStr[I] = '£' then
          Result := Result + '%C2%A3'
        else
          Result := Result + '%' + IntToHex(Ord(DecodedStr[I]), 2)
      else if not (DecodedStr[I] = ' ') then
        Result := Result + DecodedStr[I]
      else
        begin
          Result := Result + '%20'
        end;
    end;
end;

constructor TTextMarketerSMS.Create;
begin
  inherited;
  FHttp := TIdHTTP.Create(nil);
end;

destructor TTextMarketerSMS.Destroy;
begin
  FHttp.Free;
  inherited;
end;

function TTextMarketerSMS.SendSms(AOriginator, ANumber, AMessage: string;
  AXmlResponse: Boolean): string;
var
  AResult: Boolean;
  AParams: AnsiString;
  AResponse: TStringList;
begin
  AResponse := TStringList.Create;
  try
    AParams := '';
    AParams := AParams + ('?username='+FUsername);
    AParams := AParams + ('&password='+FPassword);
    AParams := AParams + ('&number='+ANumber);
    AParams := AParams + ('&orig='+UrlEncode(AOriginator));
    AParams := AParams + ('&message='+UrlEncode(AMessage));
    if AXmlResponse then AParams := AParams + ('&option=xml');
    try
      Result := FHttp.Post(C_HTTP_URL+AParams, AResponse);
    except
      Result := '';
    end;
  finally
    AResponse.Free;
  end;
end;

end.

Popularity: 11%






Related posts:

  1. .NET Examples
    Example of a .NET Bulk SMS Gateway / API integration For more information regarding the bulk sending API click here....
  2. Bulk SMS API ASP Help
    Using standard ASP libraries <% url=”http://www.textmarketer.biz/gateway/?username=#&password=#&number=#&message=msg&orig=nameORnumber&option=xml” Set objXMLDoc = CreateObject(“Microsoft.XMLDOM”) objXMLDoc.async = False objXMLDoc.load(url) status = objXMLDoc.documentElement.selectSingleNode(“//response”).getAttribute(“status”) if status =...
  3. Using our short code and gateway APIs to create a game
    The Concept To create an interactive game using Text Messaging and to show how easy it is to create interactive...
  4. SMS Gateway API – Specification
    This blog post has been superseded with our website documentation It is recommended that you use the  RESTful version of the API which has largely superseded this document...
  5. PHP 5 SMS Send Class implementing listeners on our SMS Gateway
    Class Name: SendSMSNotifier This class is designed around the FREE Text Marketer SMS API, you need to sign up here...
  6. PHP and SMS
    PHP is the very popular web scripting language, to make things easy for the PHP programmer we have provided some...
  7. Is there such a thing as ‘quality’ in Bulk SMS?
    There are a vast number of different ‘gateways’ that bulk sms service providers can use to connect to the UK...
  8. Concatenated “Long Message” SMS feature now Live for the Bulk SMS system and the SMS Gateway
    You can now send text messages longer than 160 characters, in fact up to 612 characters which arrive as 1...
  9. How to integrate our SMS Gateway API into your systems
    Introduction Adding SMS as a communication method to a system is often very useful, for instance you don’t have issues...
  10. How RoughTrax increased sales by over 19% for next to nothing using Bulk SMS – could you?
    Further to our article, Top 5 Tips for increasing sales using Bulk SMS, one of our customers RoughTrax (a mail...

Comments are closed.