Created
March 30, 2018 18:08
-
-
Save RudolfVonKrugstein/7aa07f8cda335765e77ec9a11611a5b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def areWeInPoll(poll, userId): | |
for participant in poll["participants"]: | |
if participant["userId"] == userId: | |
return True | |
return False | |
with requests.Session() as s: | |
res = s.post("https://doodle.com/api/v2.0/users/oauth/token", json={ "email": "<user-name>", "password": "<password>"} ).json() | |
name = res["name"] | |
userId = res["id"] | |
accessToken = res["accessToken"] | |
s.get("https://doodle.com/api/v2.0/users/me/cookie-from-access-token", headers={ 'Access-Token': accessToken } ) | |
s.cookies.set("token", accessToken, domain="doodle.com") | |
myPolls = s.get("https://doodle.com/np/users/me/dashboard/myPolls", params={ 'locale': 'de_DE', 'fullList': 'true', 'token': accessToken } ).json() | |
otherPolls = s.get("https://doodle.com/np/users/me/dashboard/otherPolls", params={ 'locale': 'de_DE', 'fullList': 'true', 'token': accessToken } ).json() | |
print("Your polls:") | |
for poll in otherPolls["otherPolls"]["otherPolls"]: | |
print(poll["title"]) | |
if poll["title"].find("SoccArena") != -1: | |
pollInfo = s.get("https://doodle.com/api/v2.0/polls/" + poll["id"]).json() | |
print("That is our poll, are we already in it?") | |
if areWeInPoll(pollInfo, userId): | |
print("-------> Yes") | |
else: | |
print("-------> No") | |
print("Inserting us") | |
preferences = [1] * len(pollInfo["options"]) | |
res = requests.post("https://doodle.com/api/v2.0/polls/" + pollInfo["id"] + "/participants", json={ "name" : name, "preferences": preferences, "optionsHash": pollInfo["optionsHash"], "userId": userId }) | |
print(res.text) | |
else: | |
print("Poll not interesting") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment