Skip to content

Instantly share code, notes, and snippets.

@Jatapiaro
Last active October 23, 2017 23:45
Show Gist options
  • Save Jatapiaro/5f8da7655adc77168a066fb1b0d3e723 to your computer and use it in GitHub Desktop.
Save Jatapiaro/5f8da7655adc77168a066fb1b0d3e723 to your computer and use it in GitHub Desktop.
Lis of TinderAPI for get Ig of Spotify information. Using python 2
# encoding: utf8 1,1 Top# encoding: utf8
import argparse
from datetime import datetime
import json
from random import randint
import requests
import sys
from time import sleep
"""
Using python just to make it quick, and wait until the decision
of create the native build or use phonegap with ts
"""
"""
IMPORTANT UPDATE: The API only respond with the following HTTP codes
* 500
* 400
* 200
"""
headers = {
'app_version': '8',
'platform': 'ios',
}
fb_id = '{ your fb user id here }'
fb_auth_token = '{ your fb auth token here }'
class User(object):
def __init__(self, data_dict):
self.d = data_dict
@property
def user_id(self):
return self.d['_id']
"""
This is curious, ping get a lot of different data according to the params
It can get your location, your last visit to the app and if you make a put
Instead of a get it changes the location.
"""
@property
def ago(self):
raw = self.d.get('ping')
if raw:
d = datetime.strptime(raw, '%Y-%m-%dT%H:%M:%S.%fZ')
secs_ago = int(datetime.now().strftime("%s")) - int(d.strftime("%s"))
if secs_ago > 86400:
return u'{days} days ago'.format(days = secs_ago / 86400)
elif secs_ago < 3600:
return u'{mins} mins ago'.format(mins = secs_ago / 60)
else:
return u'{hours} hours ago'.format(hours = secs_ago / 3600)
return '[unknown]'
@property
def bio(self):
try:
x = self.d['bio'].encode('ascii', 'ignore').replace('\n', '')[:50].strip()
except (UnicodeError, UnicodeEncodeError, UnicodeDecodeError):
return '[garbled]'
else:
return x
@property
def age(self):
raw = self.d.get('birth_date')
if raw:
d = datetime.strptime(raw, '%Y-%m-%dT%H:%M:%S.%fZ')
return datetime.now().year - int(d.strftime('%Y'))
return 0
"""
This is where all the data of ig and spotify is preserved along
with lot of data from the user. It's a simple JSON
on the final build we can use some Map library for it.
"""
@property
def metadata(self):
raw = self.d.get('meta')
print ( raw )
return raw
def __unicode__(self):
return u'{name} ({age}), {distance}km, {ago}'.format(
name = self.d['name'],
age = self.age,
distance = self.d['distance_mi'],
ago = self.ago
)
"""
With these you can get your auth token for tinder,
using your facebook token and user id.
"""
def auth_token(fb_auth_token, fb_user_id):
h = headers
h.update({'content-type': 'application/json'})
req = requests.post(
'https://api.gotinder.com/auth',
headers = h,
data = json.dumps({'facebook_token': fb_auth_token, 'facebook_id': fb_user_id})
)
try:
return req.json()['token']
except:
return None
def recommendations(auth_token):
h = headers
h.update({'X-Auth-Token': auth_token})
r = requests.get('https://api.gotinder.com/user/recs', headers = h)
if r.status_code = = 401 or r.status_code = = 504:
raise Exception('Invalid code')
print r.content
if not 'results' in r.json():
print r.json()
for result in r.json()['results']:
yield User(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment