-
Notifications
You must be signed in to change notification settings - Fork 4
/
message.py
46 lines (31 loc) · 1.15 KB
/
message.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
#Send SMS using PYTHON
from subprocess import *
try:
import urllib # Python URL functions
import urllib2
authkey = "221378ArPexh2OaX5b29a485" # Your authentication key.
with open('message.txt', 'r') as f:
lines = f.read().splijuggutlines()
last_line = lines[-1]
mobiles = last_line # Multiple mobiles numbers separated by comma.
message = "Test message" # Your message to send.
sender = "112233" # Sender ID,While using route4 sender id should be 6 characters long.
route = "default" # Define route
# Prepare you post parameters
values = {
'authkey' : authkey,
'mobiles' : mobiles,
'message' : message,
'sender' : sender,
'route' : route
}
url = "https://control.msg91.com/api/sendhttp.php" # API URL
postdata = urllib.urlencode(values) # URL encoding the data here.
req = urllib2.Request(url, postdata)
response = urllib2.urlopen(req)
output = response.read() # Get Response
print(output) # Print Response
print(mobiles)
except:
print("Message Error")
call('python3 login.py',shell=True)