Coder Social home page Coder Social logo

django-sendsms's Introduction

django-sendsms

https://coveralls.io/repos/github/stefanfoulis/django-sendsms/badge.svg?branch=master https://github.com/stefanfoulis/django-sendsms/workflows/Django%20Send%20SMS%20Build/badge.svg?branch=master

A simple api to send SMS messages with django. The api is structured the same way as Django's own email api.

Installation

pip install django-sendsms

Configure the SENDSMS_BACKEND (defaults to 'sendsms.backends.console.SmsBackend'):

SENDSMS_BACKEND = 'myapp.mysmsbackend.SmsBackend'

Basic usage

Sending SMSs is like sending emails:

from sendsms import api
api.send_sms(body='I can haz txt', from_phone='+41791111111', to=['+41791234567'])

You can also make instances of SmsMessage:

from sendsms.message import SmsMessage
message = SmsMessage(body='lolcats make me hungry', from_phone='+41791111111', to=['+41791234567'])
message.send()

Custom backends

Creating custom SmsBackend s:

from sendsms.backends.base import BaseSmsBackend
import some.sms.delivery.api

class AwesomeSmsBackend(BaseSmsBackend):
    def send_messages(self, messages):
        for message in messages:
            for to in message.to:
                try:
                    some.sms.delivery.api.send(
                        message=message.body,
                        from_phone=message.from_phone,
                        to_phone=to,
                        flashing=message.flash
                    )
                except:
                    if not self.fail_silently:
                        raise

Then all you need to do is reference your backend in the SENDSMS_BACKEND setting.

Running tests

python setup.py test

Or better, install and run "tox".

Contributing

Pull requests are very welcome. Please make sure code is formatted using black and isort.

django-sendsms's People

Contributors

ataylor32 avatar codesankalp avatar denizdogan avatar endormi avatar iraycd avatar kelvinwong-ca avatar mixxorz avatar pakal avatar pawl-bb avatar psychok7 avatar reidransom avatar stefanfoulis avatar superalex avatar xiscosc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-sendsms's Issues

Upgrade twilio library

PR #14 has been submitted for this.

Upgrading will allow for longer SMS messages and enable delivery tracking within twilio

Django 1.8 warning due to use of deprecated import_module

Hello! When using Django 1.8.2 the following Django warning is raised when the api or utils is imported:

RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9.

A backwards compatible fix would be to try and import the import_module from Python 2.7 and later, and if an ImportError is encountered, try the older Django importlib import.

See: https://docs.djangoproject.com/en/1.8/releases/1.7/#django-utils-dictconfig-django-utils-importlib

I have prepared a patch.

Tina

1974 2052 false sample sms message true {
"smsServiceRequest": {
"messages": {
"message": {
"startTimestamp": "0",
"expiryTimestamp": "0",
"priorityService": "true",
"recipients": {
"recipient": {
"mobile": "+13143039178"
}
},
"content": "sample sms message"
},
"channel": "voicesms"
}
}
}

<

Fix testsuite for python3 and Django 2.0

Currently there seem to be problems to run the testsuite in python3 (Django settings.configure() issues) and some code in backends seems to be failing in py3.

Test with

tox -e py36-dj20
tox -e py36-dj111

Implement SMS Global backend

Request for implementation for SMS Global backend.

I'll submit a pull request for my implementation of this shortly.

Free Use

Hello everyone. I want to explode the sending of SMS in my future sites and by doing research I came across your API. But I wonder if sending SMS through it can cover the whole world and if it's free, what are the limitations?
Thank you.

New release

Hi,

Could you please issue a new release of django-sendsms ? Last release is 5 months ago, and I think it makes sense to issue new release from latests commits and pull request. I would like to install project dependencies directly from pypi, not from github repos. What do you think ?

Some new backends.

Hello!
I have implemented a similar application in a private project and I have several backends that could easily be adapted to your app.
If you want, I can adapt for your application!

Tests for python 2.7 are failing -- drop support?

The python 2.7 tests are failing. It looks like a dependency (probably indirectly through one of the optional dependencies) more_itertools does not support python 2.7 anymore (since version 6.0.0).

Question is:
Should we try to fix this?
Or use this as an opportunity to drop python 2 support?

enable and disable unicode

This PR for bulksms backend assumes all messages are unicode #17 but this is wrong. a user might not use unicode in order to increase the char number.

I will try to fix this a.s.a.p

RQ Backend

I've made a simple backend to make messages send asynchronously with RQ. It's just this:

from sendsms.backends.base import BaseSmsBackend
from sendsms.api import get_connection

from django.conf import settings
from django_rq import job


@job
def send_messages(messages):
    connection = get_connection(getattr(settings, 'RQ_SENDSMS_BACKEND', None))
    connection.send_messages(messages)


class SmsBackend(BaseSmsBackend):

    def send_messages(self, messages):
        send_messages.delay(messages)

Then you set your real backend in settings.py

# in settings.py
RQ_SENDSMS_BACKEND = 'sendsms.backends.twiliorest.SmsBackend'

Would you be interested if I made this into a PR?

Setup testsuite

On travis or circleci.
All the things:

  • python2/3
  • Django 2.0

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.