charliewolf / pynder

:fire: Python client for tinder api
Other
638 stars 142 forks source link

Trying to add picture upload #77

Open DylanVanAssche opened 8 years ago

DylanVanAssche commented 8 years ago

I'm trying to add picture upload to Pynder by using this API from our friends here:

https://github.com/tinderjs/tinderjs/blob/master/tinder.js#L451

I wrote this:

TINDER_IMAGE_HOST= 'https://imageupload.gotinder.com'
session.post(TINDER_IMAGE_HOST + '/image?client_photo_id=ProfilePhoto' + str(int(time.time())), files={'media': open('test.jpeg', 'rb')})

However I get a HTTP 500 error while it works perfectly in NodeJS... They add this: '.field('userId', _this.userId)' to their request but I can't find out how I can add this to my request with Python. Anyone an idea?

Dylan Van Assche

charliewolf commented 8 years ago

from eyeballing it I think you want: session.post(TINDER_IMAGE_HOST + '/image?client_photo_id=ProfilePhoto' + str(int(time.time())), data={'userid': INSERT_USERID_HERE}, files={'file': open('test.jpeg', 'rb')})

charliewolf commented 8 years ago

also you want str(int(time.time() * 1000)) to match the JS version.

DylanVanAssche commented 8 years ago

Still a HTTP 500 error :( Adding image upload would be very nice :+1:

DylanVanAssche commented 8 years ago

I was able to add FB picture support with requests but I don't understand the hierarchy behind Pynder how this request is written:

ydistance_percent = 0
xdistance_percent = 0
yoffset_percent = 0
xoffset_percent = 0
data = json.dumps({"transmit": "fb", "assets": [{"ydistance_percent": ydistance_percent,"id": fb_picture_id,"xoffset_percent": xoffset_percent,"yoffset_percent": yoffset_percent,"xdistance_percent": xdistance_percent}]})
pictures = session.post(constants.TINDER_HOST + '/media', data=data)

the variable 'pictures' contains a list of all the images (including the new ones) in the account. However, uploading to Tinder directly still doesn't work.