-
Notifications
You must be signed in to change notification settings - Fork 4
/
utilityFunctions.py
70 lines (65 loc) · 2.47 KB
/
utilityFunctions.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
60
61
62
63
64
65
66
67
68
69
70
import urllib
import urllib2
from pymongo import MongoClient
db=MongoClient('mongodb://brsrc:[email protected]:28559/brosource')['brosource']
# function to get rerquired userdata only
def setUserInfo(userInfo, *args):
userdata = {}
for arg in args:
try:
userdata[arg] = userInfo[arg]
except:
pass
if (arg=='certifications' or arg=='education_details'):
userdata[arg]=str(','.join(userdata[arg]))
return userdata
def getSkills(userSkills):
skills=[]
for skill in userSkills:
try:
skills.append(db.skills.find({skill:{'$exists':1}},{skill:1})[0][skill])
except:
pass
return skills
# function to hash passwords
def hashingPassword(password):
salt=[password[i] for i in range(0,len(password),2)]
postsalt=''.join(salt[:len(salt)/2])
presalt=''.join(salt[len(salt)/2:])
return (presalt+password+postsalt)
# function to send the token for forgot password
def sendRequestToken(contact, authToken):
authkey = "81434A3rGba9dY75583ac07"
sender = "BROSRC"
message = "Auth Token for Changing Password in Brosource is "+str(authToken)
route = "transactional"
values = {
'authkey' : authkey,
'mobiles' : contact,
'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)
# function to send welcome message to new user
def sendMessage(number,message):
authkey = "81434A3rGba9dY75583ac07" # Your authentication key.
mobiles = number # Multiple mobiles numbers separated by comma.
message = message # Your message to send.
sender = "BROSRC" # Sender ID,While using route4 sender id should be 6 characters long.
route = "transactional" # 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)