Giter Club home page Giter Club logo

django-skebby's Introduction

django-skebby

A simple Django app to send sms by Skebby.

Usage

In settings.py:

SKEBBY_USERNAME = 'yourskebbyusername'
SKEBBY_PASSWORD = 'yourskebbypassword'

# If SSL cert is not valid
SKEBBY_VERIFY_SSL_CERTIFICATE = False

# If SSL does not work at all
#SKEBBY_URL = "http://gateway.skebby.it/api/send/smseasy/advanced/http.php"

# If you have *requested and obtained* the raise to 100000 messages per request
#SKEBBY_MAX_RECIPIENTS = 100000

# default method is classic
SKEBBY_DEFAULT_METHOD = "basic"

In your code:

from django_skebby.utils import Sms, skebby_credit_left

# greetings to some people
template = "Good {{ festivity }}{% if friend %} {{ friend }}{% endif %}!"
ctx = {'festivity': 'birthday'}
sms = Sms(template, ["39123456789", "3912346788"], sender_string="Your friend", ctx=ctx)
ret = sms.send()
# Skebby has a recipient limit of 50000 numbers that can be raised to 100000 on request
# The app will take care of itself depending on settings.SKEBBY_MAX_RECIPIENTS
failed_requests = [r for r in ret if r.skebby_error]
if failed_requests:
    print "some errors!"

# to a special friend
ctx = {'festivity': birthday, 'friend': 'Doge'}
r = sms.send_single(ctx, "3912345679")
if r.skebby_error:
    print "failed to greet :( %s" % (r.skebby_response)

# check credit
credit = skebby_credit_left()
if credit.skebby_error:
    print "failed to get credit"
else:
    print credit.skebby_response

A view that returns the credit in json format is available, to enable it add the app:

INSTALLED_APPS = (
    ...
    'django_skebby',
)

include the urls:

url(r'^skebby/', include('django_skebby.urls')),

add use it:

<script>
$.get('/skebby/credit_left/', function(data) {
    console.log(data['credit_left']);
    console.log(data['classic_sms']);
    console.log(data['basic_sms']);
});
</script>

django-skebby's People

Contributors

xrmx avatar ilcapo77 avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

Forkers

ilcapo77

django-skebby's Issues

API review

More use cases to see what can be improved, starting from:

  • in the response body storing a dict is not self descriptive, better have body keep the original text and provide another key that stores the dict

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.