Giter Site home page Giter Site logo

rkbi / ismslib.py Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 20 KB

Library for using SSLWireless iSMS API. The goal is to provide a very easy-to-use interface.

License: GNU General Public License v3.0

Python 98.60% Shell 1.40%
sms sslwireless api python python3 isms library

ismslib.py's Introduction

Very simple and easy to use Python 3 library for integrating SSLWireless SMS API.

Installation

using virtual environment (pipenv)

pipenv install ismslib

using pip globally

python3 -m pip install ismslib

Example

from ismslib import ISMS

# Contact with SSLWireless Key Account Manager for these credentials
config = {
    "username": '<user>',
    "password": '<pass>',
    "sid": '<SID>',
}

response = ISMS.set_config(config)\
                .set_body("আসসালামু আলাইকুম").make_unicode()\
                .set_recipient(['88018XXXXXXXX', '88019XXXXXXXX'])\
                .send()

print(response) if response['error'] else print('success')

Usage

1. First we import the library

 from ismslib import ISMS

2. Set Credentials

Create a dictionary with user credentials obtained from SSLWireless.

config = {
    "username": '',  # Please add your username provided by SSLWireless
    "password": '',  # Please add your password provided by SSLWireless
    "sid": '',  # Please add your SID provided by SSLWireless
}

3. Set data

Call needed methods with valid data
ISMS.set_config(config) # Set config values
ISMS.set_body("আসসালামু আলাইকুম") #Set SMS body text, Can be English or Unicode Bangla
ISMS.make_unicode() # Use for Bangla SMS, otherwise is not needed
ISMS.set_recipient(['88018XXXXXXXX', '88019XXXXXXXX']) # list of mobile numbers to send to
ISMS.set_debug(True) # __DO NOT USE IN PRODUCTION__. Prints useful information on console.
response = ISMS.send() # Finally send SMS.
optionally, methods can be chained together
response = ISMS.set_config(config)\
                .set_body("আসসালামু আলাইকুম").make_unicode()\
                .set_recipient(['88018XXXXXXXX', '88019XXXXXXXX'])\
                .set_debug()\
                .send()

4. Check the returned response

We can print out the response in console

print(response) if response['error'] else print('success')

Return values

"send()" returns a dictionary containing 3 values
{'error': True, 'msg': 'Login FAILED. Please check your username and password.', 'json': '{"REPLY": {"PARAMETER": "OK", "LOGIN": "FAIL"}}'}
1. error [boolean] : False if SMS sent successfully, True on error
2. msg [string] : Error message. Explains the reason of failure.
3. json [json string] : Raw API response, it's there if needed.

Contribution

Star ⭐ this repo if you find it useful. Any feedback is much appreciated. For official support / user credentials, contact your Key Account Manager (KAM).

ismslib.py's People

Contributors

rkbi avatar

Stargazers

 avatar

Watchers

 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.