25 March, Saturday

Email:
Password:
Text/SMS, TTS and Voice Broadcasting - Web Based Group Messaging
Follow
SMS Text Broadcasting SMS Gateway Voice Broadcasting Text to Speech Email and Fax Broadcasting

SMS Gateway - JSON API

New JSON API for sending SMS.

Matrix SMS Gateway JSON API is under heavy development/testing.
First version of API that allows sending SMS and TTS messages has been released in September 2014.

More functions (e.g. send Voice messages) will be added to JSON API shortly.
CPAN SMS::Matrix Perl module.
Here is a local copy: SMS::Matrix Perl module.




Examples of the usage of SMS Gateway API:

SMS Gateway - Send SMS - HTTP JSON Post : Perl Example

use LWP::UserAgent;
use HTTP::Request::Common;
use Data::Dumper;
use JSON();

my $p =
{
 username  => 'user@website.com',
 password  => 'mypassword',
 txt       => 'This is a test, pls ignore',
 phone     => '13471234321',   ## don't forget country prefix! (E.g 1 for US/Canada)

 ## optional parameters
 callerid  => '12501231233',   ## for owners of virtual phone numbers (2-way sms)
 tts       => 1, # TTS fallback
};

my $p_json = JSON::to_json ($p);

my $ua = LWP::UserAgent->new();
my $res = $ua->request
(
 POST             'https://www.smsmatrix.com/matrix.json',
 Content_Type  => 'application/json',
 Content       => $p_json
);

if ($res->is_error) { die "HTTP Error\n"; }
my $resp = undef;
eval { $resp = JSON::from_json ($res->content); };
print Data::Dumper ($resp);



SMS Gateway - Send SMS - HTTP JSON Post : Node.js JavaScript Example

var options =
{
 uri:     'https://www.smsmatrix.com/matrix.json',
 method:  'POST',
 json:    {
           username: 'user@website.com',
           password: 'mypassword',
           txt:      'This is a test, pls ignore',
           phone:    '13471234321'
          }
};

var request = require ('request');  // https://github.com/mikeal/request

request (options, function (error, response, body)
{
 if (!error && (response.statusCode < 400))
  {
   console.log (body);
   var r = JSON.parse (body);
   console.log (r.STATUSTXT);
  }
});



SMS Gateway - Send TTS - HTTP JSON Post : Perl Example

use LWP::UserAgent;
use HTTP::Request::Common;
use Data::Dumper;
use JSON();

my $p =
{
 username  => 'user@website.com',
 password  => 'mypassword',
 txt       => 'This is a test, pls ignore',
 phone     => '13471234321',   ## don't forget country prefix! (E.g 1 for US/Canada)
 gender    => 'female',
 language  => 'en',

 ## optional parameters
 callerid  => '12501231233',   ## for owners of virtual phone numbers
 response  => 0,
};

my $p_json = JSON::to_json ($p);

my $ua = LWP::UserAgent->new();
my $res = $ua->request
(
 POST             'https://www.smsmatrix.com/matrix_tts.json',
 Content_Type  => 'application/json',
 Content       => $p_json
);

if ($res->is_error) { die "HTTP Error\n"; }
my $resp = undef;
eval { $resp = JSON::from_json ($res->content); };
print Data::Dumper ($resp);



SMS Gateway - Get Balance - HTTP JSON Post : Perl Example

use LWP::UserAgent;
use HTTP::Request::Common;
use Data::Dumper;
use JSON();

my $p =
{
 username  => 'user@website.com',
 password  => 'mypassword',
};

my $p_json = JSON::to_json ($p);

my $ua = LWP::UserAgent->new();
my $res = $ua->request
(
 POST             'https://www.smsmatrix.com/balance.json',
 Content_Type  => 'application/json',
 Content       => $p_json
);

if ($res->is_error) { die "HTTP Error\n"; }
my $resp = undef;
eval { $resp = JSON::from_json ($res->content); };
print Data::Dumper ($resp);