Dominic Sonntag
and 1 contributors

NAME

SMS::API::CMTelecom - SMS API for cmtelecom.com

VERSION

Version 0.01

SYNOPSIS

    use SMS::API::CMTelecom;
    my $sms = SMS::API::CMTelecom->new(
        product_token => '00000000-0000-0000-0000-000000000000',
    );

    $sms->send(
        sender     => '00480000111111111',
        message    => 'please call me!',
        recipients => '00490000000000000',
        reference  => 293854,
    );

    # bulk send to many recipients:
    $sms->send(
        sender     => '00480000111111111',
        message    => 'please call me!',
        recipients => ['00490000000000000', '00480000000000', '004300021651202'],
        reference  => 293854,
    );

    my $number = '00480000111111111';
    if ($sms->validate_number($number)) {
        print "$number is a valid phone number.\n"
    } else {
        print "$number is no valid phone number.\n"
    }

    my $number_details = $sms->number_details($number);
    print "$number was ported.\n" if $number_details->{ported};

METHODS

new(%options)

Instantiate and initialise object with the following options:

product_token => $product_token

The product token is required to authenticate with the CM Telecom API.

sender => $sender

Optional. SMS sender number.

send

message => $message

Mandatory. Message text to send.

recipients => $recipients

Mandatory. May be a scalar containing one phone number or an array reference holding multiple scalars containing one phone number each.

sender => $sender

Optional if already given as parameter to new. Can also be set globally when construction the object with new().

If sending fails, undef is returned, otherwise a hashref with some status information:

    {
        messages => [
            {
                messageDetails => undef,
                parts          => 1,
                reference      => 51314,
                status         => "Accepted",
                to             => "0049123456784510",
            },
        ],
    }

You can retrieve the error message via

    my $msg = $sms->error_message();

validate_number $number

Checks if the given phone number is valid and provides additional information, e.g. how the number should be formatted. Returns 1 if the number is valid, a false value otherwise.

number_details $number

Returns carrier, country, timezone and number type information about the given number.

error_message

Returns the last set error message.

AUTHOR

Dominic Sonntag, <dominic at s5g.de>

BUGS AND SUPPORT

Please report any bugs or feature requests on Github: https://github.com/sonntagd/SMS-API-CMTelecom/issues

LICENSE AND COPYRIGHT

Copyright 2017 Dominic Sonntag.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0