Giter Site home page Giter Site logo

django-smsbrana's Introduction

About django-smsbrana

This code incompletely implements api from smsbrana connect api

You can call three commands :

  • send_sms - sends sms
  • inbox - shows status of your inbox (your sms on server) and sms delivery reports
  • credit_info - how much credit you have left

It also provides notification callback view function. Which will be called upon arrival of new message into your inbox.

Installation

pip install git+git://github.com/vlinhart/django-smsbrana.git#egg=smsbrana
add 'smsbrana' to the INSTALLED_APPS.
add url(r'^smsbrana/', include('smsbrana.urls', namespace="smsbrana")) to urls.py

Configuration

It's necessary to set several constants in settings.py:

SMS_CONNECT_LOGIN = username
SMS_CONNECT_PASSWORD = passsword

optional is:
SMS_CONNECT_SECURE = True #if you want to use plaintext password sending, don't
SMS_CONNECT_SENDER_ID = 'some sender id' #from smsbrana configuration

Usage

Have a look at the tests to see how the class SmsConnect is used. Basically like this:

sc = SmsConnect()
result = sc.send_sms(number='777111222', message='msg') #there are more optional params
#in result is a dict containing this keys - 'err','price','sms_count','credit','sms_id'

All API calls can raise SmsConnectException, you should handle it.

Signals

There are two signals provided.

  • smsconnect_notification_received -- caled when view notification function is called, providing request and result of inbox API call
  • smsconnect_sms_sent -- called when SMS is sent, provides phone_number, text and result of the API call

View function

smsconnect_notification will handle notification calls from smsbrana.cz which will be issued upon new message arrival or sms delivery. It will fire the smsconnect_notification_received signal. This function is updating state of SentSms model instances, setting their flags, delivered and delivered_date.

Model SentSms

You can use this model to track sent SMSes. Some helpful methods on the model are also provided.

  • generate_sms_verification_code(length=6) -- if you want to use model for sending verification codes
  • can_send_from_ip(ip, time_allowance=30) -- checks if there were smses sent from IP address in time_allowance seconds ago
  • sms_to_number_delivered_in_last_hours(hours, phone_number) -- if to specified phone number SMS was delivered hours ago up to now

This is not exhaustive documentation, read the code.

django-smsbrana's People

Contributors

farin avatar vlinhart avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

raviteja91 farin

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.