From b2660a7e0324007bbb0d3cdfff69e7b6e5b47620 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Fri, 1 Jan 2021 21:25:41 +0100 Subject: [PATCH] Starting partial API documentation Implement simple HTTP request object based on urllib --- .gitignore | 4 ++++ apidoc/images.md | 1 + apidoc/login.md | 5 +++++ apidoc/messages.md | 47 ++++++++++++++++++++++++++++++++++++++++++++++ http.py | 6 ++++++ 5 files changed, 63 insertions(+) create mode 100644 .gitignore create mode 100644 apidoc/images.md create mode 100644 apidoc/login.md create mode 100644 apidoc/messages.md create mode 100644 http.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..049ac48 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +logs/ +*.pyc +__pycache__/ +database.db \ No newline at end of file diff --git a/apidoc/images.md b/apidoc/images.md new file mode 100644 index 0000000..ab47522 --- /dev/null +++ b/apidoc/images.md @@ -0,0 +1 @@ +Endpoint: https://www.planetromeo.com/img/usr/original/0x0/URL_TOKEN.jpg (where URL_TOKEN is from the message object) \ No newline at end of file diff --git a/apidoc/login.md b/apidoc/login.md new file mode 100644 index 0000000..32b5cff --- /dev/null +++ b/apidoc/login.md @@ -0,0 +1,5 @@ +Endpoint: https://www.planetromeo.com/api/v4/session?lang=en + +Payload: {"username":"LOGIN_USER","password":"LOGIN_PASSWORD","keep_login":false} + +Sample Response: {"user_id":"USER_ID","username":"LOGIN_USER","session_id":"SESSION_ID","online_status":"ONLINE","is_plus":true,"is_free_plus":false,"payment_group":"A","confirmed_account":true} \ No newline at end of file diff --git a/apidoc/messages.md b/apidoc/messages.md new file mode 100644 index 0000000..afca7fd --- /dev/null +++ b/apidoc/messages.md @@ -0,0 +1,47 @@ +Endpoint: https://www.planetromeo.com/api/v4/messages?lang=en&length=MESSAGES_COUNT + +Headers: + +* X-Api-Key: vuEp8o93b34CxUCljSMFEdhI70qDWtuk (seems to be hard-coded) +* X-Site: planetromeo (might not be necessary, leaving it in anyway) +* X-Session-Id: SESSION_ID (from login) + +Sample response: + +{ + "cursors":{ + (This should be irrelevant if MESSAGES_COUNT is high enough – there doesn't seem to be a limit for that) + }, + "items":[ + { + "to":"RECIPIENT_ID", + "text":"TEXT_CONTENT", + "attachments":[ + { + "type":"IMAGE", + "error_text":"This App is outdated and cannot support all message features. Please log in to on www.planetromeo.com or update to the most recent App version.", + "params":{ + "id":"ATTACHMENT_ID", + "owner_id":"ATTACHMENT_SENDER (usually equals SENDER_ID)", + "url_token":"URL_TOKEN", + "auth_token":"AUTH_TOKEN (seems irrelevant)" + "width":IMAGE_WIDTH (int), + "height":IMAGE_HEIGHT (int), + "rating":"IMAGE_RATING", + "is_public":ATTACHMENT_PUBLIC (bool, usually false?) + } + }, + (More attachment objects) + ], + "id":"MESSAGE_ID", + "from":"SENDER_ID", + "date":"2000-01-01T12:00:00+0000", + "expires":"2000-01-08T12:00:00+0000", + "folder":"MESSAGE_FOLDER", + "unread":READ_STATUS (bool), + "locked":LOCKED_STATUS (?, bool), + "spam":SPAM_STATUS (bool) + }, + (More message objects) + ] +} \ No newline at end of file diff --git a/http.py b/http.py new file mode 100644 index 0000000..3d41a36 --- /dev/null +++ b/http.py @@ -0,0 +1,6 @@ +from urllib.request import Request as UrllibRequest + +class Request(UrllibRequest): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.headers["user-agent"] = "romeotools (https://kumig.it/kumitterer/romeotools)" \ No newline at end of file