Giter VIP home page Giter VIP logo

libpynexmo's Introduction

nexmomessage

A Python wrapper for the Nexmo API.

Installation

$ pip install -e git+https://github.com/marcuz/libpynexmo.git#egg=nexmomessage

Quick start (sending a message)

First you need to load up the package and construct a dictionary with your API credentials and message, like this:

from nexmomessage import NexmoMessage

msg = {
	'reqtype': 'json',
	'api_key': YOUR_API_KEY,
	'api_secret': YOUR_API_SECRET_KEY,
	'from': YOUR_PHONE_NUMBER,
	'to': DESTINATION_PHONE_NUMBER,
	'text': 'Hello world!'
}
sms = NexmoMessage(msg)
sms.set_text_info(msg['text'])

Then you have a choice. For a "fire and forget" approach to sending a message, use the send_request method, like this:

sms.send_request()

This method call returns the message data if the message was sent successfully, or raises an exception if there was an error.

response = sms.send_request()

if response:
    # do something with response data
else:
    # handle the error

Troubleshooting

Remember that phone numbers should be specified in international format.

The Nexmo documentation contains a list of error codes which may be useful if you have problems sending a message.

Please report all bugs/issues via the GitHub issue tracker.

libpynexmo's People

Contributors

axiom avatar changtimwu avatar dangyogi avatar kaboing avatar kunalg avatar marcuz avatar pmarti 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libpynexmo's Issues

Lib forces unicode encoding when sending non ascii characters, even if they are in the GSM 03.38 alphabet

Hi,

When sending a text message, the library tries to decode the message as ascii and if it fails then encodes the text as utf-8 and sets the type parameter to unicode which is not correct.

For example, there are many characters in the GSM 03.38 alphabet that are not ascii but do not require unicode encoding. Flagging these messages as type=unicode implies that the maximum length allowed for messages decreases to 70 characters and makes many messages to be sent as multipart (and charged for each part) while it's not required.

Finally, this may cause some encoding issues with some network or phones.

Best regards,
Fabien

PyPi release

Why no love for PyPI? git urls and tarballs are no good if you want to reference deps in setup.py.

Missing license

Hi,

What is the license of this code?

Without any license, it's not really usable, is it?

Thanks.

installation of nexmomessage gives me error

C:\Users\njain>c:\Python27\Scripts\pip install -e git+https://github.com/marcuz/
libpynexmo.git#egg=nexmomessage
Traceback (most recent call last):
File "c:\Python27\Scripts\pip-script.py", line 9, in
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "C:\Python27\lib\site-packages\distribute-0.6.49-py2.7.egg\pkg_resources.
py", line 345, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "C:\Python27\lib\site-packages\distribute-0.6.49-py2.7.egg\pkg_resources.
py", line 2381, in load_entry_point
return ep.load()
File "C:\Python27\lib\site-packages\distribute-0.6.49-py2.7.egg\pkg_resources.
py", line 2087, in load
entry = import(self.module_name, globals(),globals(), ['name'])
File "C:\Python27\lib\site-packages\pip__init__.py", line 10, in
from pip.util import get_installed_distributions, get_prog
File "C:\Python27\lib\site-packages\pip\util.py", line 17, in
from pip.vendor.distlib import version
File "C:\Python27\lib\site-packages\pip\vendor\distlib\version.py", line 13, i
n
from .compat import string_types
File "C:\Python27\lib\site-packages\pip\vendor\distlib\compat.py", line 38, in

from HTMLParser import HTMLParser
File "C:\Python27\lib\HTMLParser.py", line 47, in
""", re.VERBOSE)
File "C:\Python27\lib\re.py", line 190, in compile
return _compile(pattern, flags)
File "C:\Python27\lib\re.py", line 242, in _compile
raise error, v # invalid expression
sre_constants.error: nothing to repeat

C:\Users\njain>

Sending a message

In the README, it says: "Then you have a choice. For a "fire and forget" approach to sending a message, use the send_request method".

In addition to this 'fire and forget' approach, what is the other choice(s)? In addition, does this 'fire and forget' approach imply that the the requests to Nexmo are somehow asynchronous, i.e. I don't need to wait for Nexmo API to respond before continuing the rest of my code?

Broken link

The link in the README to the documentation about the response codes is broken.

Can't iterate and create new NexmoMessage objects, REST calls

When trying to iterate through an array of recipients (for x in array), I tried to create new NexmoMessage objects for each and call the REST API, but I get the "'builtin_function_or_method' object is unsubscriptable" error. It appears there is a builtin function being used that won't allow the iteration to perform.

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.