forked from orangedareoranges/owler-status-updater
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathowlerpythonGITHUB.py
More file actions
31 lines (30 loc) · 1.2 KB
/
Copy pathowlerpythonGITHUB.py
File metadata and controls
31 lines (30 loc) · 1.2 KB
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
import requests
import json
from base64 import b64encode # Shouldn't be necessary, but keep it still.
# Login section
username = "Sample Text"
password = "Sample Text"
login_request = requests.get("https://api.owler.cloud/v1/account/verify_credentials.json", auth=(username, password))
# Status code checks
if login_request.status_code == 401:
print("Failed to authenticate due to bad username or password.")
exit(1)
elif login_request.status_code == 400:
print("Failed to authenticate due to a server or validation error.")
exit(1)
# Owler status stuff
url = "https://api.owler.cloud/v1/statuses/update.json"
print("Login successful!\nSubmit a status:")
x = input()
print("Your status is: " + x)
post_request = requests.post(f"{url}?status={x}&source=a python script", auth=(username, password)) # update request
# Status code checks 2
if post_request.status_code == 401:
print("Failed to post due to bad login credientials (This should *not* happen, but it happened anyways. Go figure.)")
exit(1)
elif post_request.status_code == 400:
print("Error! Error!")
exit(1)
elif post_request.status_code == 200:
print("Success! Check your owler page now.")
exit(1)