-
Notifications
You must be signed in to change notification settings - Fork 0
/
way2sms.py
59 lines (47 loc) · 1.44 KB
/
way2sms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import requests
class sms:
def __init__(self, username, password, proxies=None):
# Using username and password, login to the way2sms server
self.url = 'http://site24.way2sms.com/Login1.action?'
self.cred = {
'username': username,
'password': password
}
self.s = requests.Session()
self.s.headers['User-Agent'] = "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:55.0) Gecko/20100101 Firefox/55.0"
self.proxyDict = proxies
self.q = self.s.post(self.url, data = self.cred, proxies = self.proxyDict)
self.loggedIn = False
if self.q.status_code == 200:
self.loggedIn = True
self.jsid = self.s.cookies.get_dict()['JSESSIONID'][4:]
def send(self, number, message):
if len(message) > 139 :
return {
"status": "ERROR",
"response": "Message length exceeded!"
}
if len(number) != 10 or (number[0] != '7' and number[0] != '8' and number[0] != '9'):
return {
"status": "ERROR",
"response": "Number Invalid!"
}
self.form_data = {
'ssaction' : 'ss',
'Token' : self.jsid,
'mobile' : number,
'message' : message,
'msgLen' : '129'
}
self.msg_url = 'http://site24.way2sms.com/smstoss.action'
self.q = self.s.post(self.msg_url, data=self.form_data, proxies=self.proxyDict)
if self.q.status_code == 200:
return {
"status": "OK",
"response": message
}
else:
return {
"status": "ERROR",
"response": "Some Error Occurred!"
}