Skip to content

kianmeng/sms-send-mocean

Repository files navigation

Cpan license Cpan version

NAME

SMS::Send::Mocean - SMS::Send driver to send messages via Mocean, https://moceanapi.com/.

SYNOPSIS

use SMS::Send;

my $gateway = SMS::Send->new(
    'Mocean',
    '_api_key' => 'foo',
    '_api_secret' => 'bar'
);

$gateway->send_sms(
    to => '+60123456789',
    ext => 'Hello',
    _from => 'foobar'
);

DESCRIPTION

SMS::Send::Mocean is a driver for SMS::Send to send message via Mocean, https://moceanapi.com/.

DEVELOPMENT

Source repository at https://github.com/kianmeng/send-sms-mocean.

How to contribute? Follow through the CONTRIBUTING.md document to setup your development environment.

METHODS

new(_api_key, _api_secret)

Construct a new SMS::Send instance.

my $gateway = SMS::Send->new(
    'Mocean',
    '_api_key' => 'foo',
    '_api_secret' => 'bar'
);

_api_key

Compulsory. The API access key used to make request through web service.

_api_secret

Compulsory. The API secret key.

send_sms(to, text, _from, [%params])

Send the SMS text to a mobile user.

# Default parameters with XML response format if the '_resp_format' field
# is not defined.
$gateway->send_sms(
    to => '+60123456789',
    ext => 'Hello',
    _from => 'foobar',
);

# With JSON response format.
$gateway->send_sms(
    to => '+60123456789',
    ext => 'Hello',
    _from => 'foobar',
    _resp_format => 'json',
);

to

Compulsory. The required field needed by SMS::Send. Only accept leading-plus number in the format of "+99 999 9999".

text

Compulsory. The required field needed by SMS::Send. The content of the SMS message. Depends on the language of the content, there is a limit of characters that can be sent.

_from

Compulsory. The login username of the Mocean API portal.

[%params]

Optional. Additional parameters that can be used when sending SMS. Check the Mocean API documentation on the available parameters. Due to the design constraints of SMS::Send::Driver, all parameters name must start with underscore. For example, '_resp_format'. This driver will convert the parameter name to equivalent format used by Mocean. In this case, '_foo_bar' will be formatted as 'mocean-resp-format'.

$gateway->send_sms(
    to => '+60123456789',
    ext => 'Hello',
    _from => 'foobar',
    _resp_format => 'json',
    _charset => 'utf-8',
);

AUTHOR

Kian Meng, Ang kianmeng@cpan.org

COPYRIGHT AND LICENSE

This software is Copyright (c) 2019 Kian Meng, Ang.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

SEE ALSO

SMS::Driver