GithubHelp home page GithubHelp logo

textmagic-rest-perl's Introduction

TextMagic Perl SDK

This library provides you with an easy way of sending SMS and receiving replies by integrating TextMagic SMS Gateway into your Perl application.

What is TextMagic?

TextMagic’s application programming interface (API) provides the communication link between your application and TextMagic’s SMS Gateway, allowing you to send and receive text messages and to check the delivery status of text messages you’ve already sent.

Installation

wget https://github.com/imissyouso/textmagic-rest-perl/archive/v2.0.650.tar.gz && \
tar zxf v2.0.650.tar.gz && \
rm -f v2.0.650.tar.gz && \
cd textmagic-rest-perl-2.0.650 && \
perl Makefile.pl && \
make && \
make install && \
cpanm --installdeps .

Usage Example

Please follow the installation instructions and execute the following Perl code:

use 5.010;
use strict;
use warnings;
use Net::Sms::TextMagicClient::ApiClient;
use Net::Sms::TextMagicClient::TextMagicApi;
use Net::Sms::TextMagicClient::Object::SendMessageInputObject;

my $client = Net::Sms::TextMagicClient::ApiClient::->new(
    username   => 'YOUR_USERNAME',
    password   => 'YOUR_PASSWORD',
    base_url  => 'https://rest.textmagic.com'
);

my $api_instance = Net::Sms::TextMagicClient::TextMagicApi::->new($client);

# Ping request example
eval {
    my $result = $api_instance->ping();
    print $result->ping;
};

if ($@) {
    warn "Exception when calling TextMagicApi->ping: $@\n";
}

# Send a new message request example
my $send_message_input_object = Net::Sms::TextMagicClient::Object::SendMessageInputObject->new(
    text => 'I love TextMagic!',
    phones => '+19998887766'
);

eval {
    my $result = $api_instance->send_message(send_message_input_object => $send_message_input_object);
    print $result->id;
};

if ($@) {
    warn "Exception when calling TextMagicApi->send_message: $@\n";
}

# Get all outgoing messages request example
eval {
    my $result = $api_instance->get_all_outbound_messages();
    print $result->resources->[0]->message_time;
};

if ($@) {
    warn "Exception when calling TextMagicApi->get_all_inbound_messages: $@\n";
}

# Upload a new avatar for a  specified contacts list (group) request example (3223 it is sample list ID)
eval {
    my $result = $api_instance->upload_list_avatar(image => "test.jpg", id => 3223);
    print $result->id;
};

if ($@) {
    warn "Exception when calling TextMagicApi->upload_list_avatar: $@\n";
}

License

The library is available as open source under the terms of the MIT License.

textmagic-rest-perl's People

Contributors

imissyouso avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.