Skip to content

Commit 7d8bd61

Browse files
committed
first commit
0 parents  commit 7d8bd61

6 files changed

Lines changed: 217 additions & 0 deletions

File tree

.gitignore

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*,cover
46+
.hypothesis/
47+
48+
# Translations
49+
*.mo
50+
*.pot
51+
52+
# Django stuff:
53+
*.log
54+
local_settings.py
55+
56+
# Flask stuff:
57+
instance/
58+
.webassets-cache
59+
60+
# Scrapy stuff:
61+
.scrapy
62+
63+
# Sphinx documentation
64+
docs/_build/
65+
66+
# PyBuilder
67+
target/
68+
69+
# IPython Notebook
70+
.ipynb_checkpoints
71+
72+
# pyenv
73+
.python-version
74+
75+
# celery beat schedule file
76+
celerybeat-schedule
77+
78+
# dotenv
79+
.env
80+
81+
# virtualenv
82+
venv/
83+
ENV/
84+
85+
# Spyder project settings
86+
.spyderproject
87+
88+
# Rope project settings
89+
.ropeproject
90+
91+
.DS_Store

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 viasocket
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# sendotp-python
2+
3+
Python package for the SendOTP API (https://sendotp.msg91.com/).
4+
5+
6+
## Installation
7+
8+
pip install sendotp
9+
10+
11+
## Basic Usage
12+
13+
```python
14+
import sendotp
15+
16+
socket = sokt.sokt('my_api_key')
17+
otpobj = sendotp('Autk-Key','my message is {{otp}} keep otp with you.')
18+
19+
20+
print otpobj.send(919981534313,'msgind')
21+
22+
print otpobj.verify(910000000000,3245)
23+
24+
print otpobj.retry(910000000000) OR
25+
print otpobj.retry(910000000000,'text')
26+
```

sendotp/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from sendotp import sendotp

sendotp/sendotp.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import json
2+
import requests
3+
from random import randint
4+
5+
6+
class sendotp:
7+
8+
def __init__(self,key,msg) :
9+
10+
self.baseUrl = "http://control.msg91.com"
11+
self.authkey = key
12+
13+
try:
14+
msg
15+
except NameError:
16+
self.msg = "Your otp is {{otp}}. Please do not share it with anybody"
17+
else:
18+
self.msg = msg
19+
20+
def actionURLBuilder(self,actionurl) :
21+
# print self.baseUrl + '/api/' +str(actionurl)
22+
print actionurl
23+
return self.baseUrl + '/api/' +str(actionurl)
24+
25+
26+
def generateOtp(self) :
27+
return randint(1000,9999)
28+
29+
def send(self,contactNumber,senderId,otp) :
30+
values = {
31+
'authkey' : self.authkey,
32+
'mobile' : contactNumber,
33+
'message' : self.msg.replace("{{otp}}", str(otp)),
34+
'sender' : senderId,
35+
'otp' : otp
36+
}
37+
print self.call('sendotp.php',values)
38+
return otp
39+
40+
def retry(self,contactNumber,retrytype='voice') :
41+
values = {
42+
'authkey' : self.authkey,
43+
'mobile' : contactNumber,
44+
'retrytype' : retrytype
45+
}
46+
print values
47+
# response = self.call('retryotp.php',values)
48+
return;
49+
50+
51+
def verify(self,contactNumber,otp) :
52+
values = {
53+
'authkey' : self.authkey,
54+
'mobile' : contactNumber,
55+
'otp' : otp
56+
}
57+
response = self.call('verifyRequestOTP.php',values)
58+
return response;
59+
60+
def call(self,actionurl,args) :
61+
url = self.actionURLBuilder(actionurl)
62+
print url
63+
payload = (args)
64+
65+
response = requests.post(url,data=payload, verify=False)
66+
print response.text
67+
return response.status_code

setup.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from setuptools import setup
2+
3+
setup(name='sendotp',
4+
version='0.0.1',
5+
description='For sending OTP via MSG91',
6+
url='https://github.com/MSG91/sendotp-python',
7+
author='Rahul Chordiya',
8+
author_email='rahul@walkover.in',
9+
license='MIT',
10+
packages=['sendotp'],
11+
zip_safe=False)

0 commit comments

Comments
 (0)