-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsession_start.py
57 lines (45 loc) · 2.64 KB
/
session_start.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
import pynder
import robobrowser #for obtaining facebook token
import re #for obtaining facebook token
#this requires also a file in the same directory named auth.info!
#the directions for auth.info are below:
auth_stream = open("auth.info")
auth_info = [line.rstrip() for line in auth_stream.readlines()]
auth_stream.close()
#facebook authentication info will be in auth.info as follows:
#line 1: facebook id number
#line 2: email
#line 3: password
#FBID = auth_info[0]
#email = auth_info[1]
#password = auth_info[2]
##this block of code was written by someone else
MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; U; en-gb; KFTHWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.16 Safari/535.19"
FB_AUTH = "https://www.facebook.com/v2.6/dialog/oauth?redirect_uri=fb464891386855067%3A%2F%2Fauthorize%2F&display=touch&state=%7B%22challenge%22%3A%22IUUkEUqIGud332lfu%252BMJhxL4Wlc%253D%22%2C%220_auth_logger_id%22%3A%2230F06532-A1B9-4B10-BB28-B29956C71AB1%22%2C%22com.facebook.sdk_client_state%22%3Atrue%2C%223_method%22%3A%22sfvc_auth%22%7D&scope=user_birthday%2Cuser_photos%2Cuser_education_history%2Cemail%2Cuser_relationship_details%2Cuser_friends%2Cuser_work_history%2Cuser_likes&response_type=token%2Csigned_request&default_audience=friends&return_scopes=true&auth_type=rerequest&client_id=464891386855067&ret=login&sdk=ios&logger_id=30F06532-A1B9-4B10-BB28-B29956C71AB1&ext=1470840777&hash=AeZqkIcf-NEW6vBd"
def get_access_token(email, password):
s = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser="lxml")
s.open(FB_AUTH)
##submit login form##
f = s.get_form()
f["pass"] = password
f["email"] = email
s.submit_form(f)
##click the 'ok' button on the dialog informing you that you have already authenticated with the Tinder app##
f = s.get_form()
s.submit_form(f, submit=f.submit_fields['__CONFIRM__'])
##get access token from the html response##
access_token = re.search(r"access_token=([\w\d]+)", s.response.content.decode()).groups()[0]
return access_token
##end borrowed block of code
FBTOKEN = (get_access_token(email=auth_info[1], password=auth_info[2]))
session = pynder.Session(facebook_id=auth_info[0], facebook_token=FBTOKEN)
#output for testing verification purposes only
#print(auth_info[0])
#print(auth_info[1])
#THIS NEXT LINE SHOULD BE COMMENTED OUT!! IT IS YOUR FACEBOOK PASSWORD!!
#print(auth_info[2]) #this line prints facebook password to the screen!
#print(FBTOKEN)
session.profile #returns username from tinder to confirm 100% working auth
session.update_location(32.78439239999999, -96.7801849) # updates latitude and longitude for your profile
session.matches()
users = session.nearby_users()