From 217fd66576fdc6d80ca2079bcee0e08e28899f8f Mon Sep 17 00:00:00 2001 From: Florent Ravenel Date: Thu, 5 Oct 2023 19:05:41 +0200 Subject: [PATCH 1/2] feat(Buffer): Add Create draft --- Buffer/Buffer_Create_draft.ipynb | 164 +++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 Buffer/Buffer_Create_draft.ipynb diff --git a/Buffer/Buffer_Create_draft.ipynb b/Buffer/Buffer_Create_draft.ipynb new file mode 100644 index 0000000000..cbcfb34454 --- /dev/null +++ b/Buffer/Buffer_Create_draft.ipynb @@ -0,0 +1,164 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "e56e2551-58d5-4923-a40d-ea2915c79024", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Naas\"" + ] + }, + { + "cell_type": "markdown", + "id": "b019ff4f-b1c7-4472-b343-0dc61887e543", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# Buffer - Create draft" + ] + }, + { + "cell_type": "markdown", + "id": "8cf7687d-ed89-4005-a767-20a3f2de4b2d", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #buffer #draft #create #socialmedia #socialnetworks #socialmediaplatforms" + ] + }, + { + "cell_type": "markdown", + "id": "95dcc57b-0b99-46e5-9c70-9693d8ba7ce9", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Firstname Lastname]()" + ] + }, + { + "cell_type": "markdown", + "id": "e9c06077-467c-45af-82e3-d011bb90f82d", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2023-10-05 (Created: 2023-10-05)" + ] + }, + { + "cell_type": "markdown", + "id": "eb508361-e1d1-4bea-a8ba-2e15c436699b", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Description:** This notebook creates a draft for Buffer, a social media platform. It is usefull for organizations to quickly create a post for their social media accounts." + ] + }, + { + "cell_type": "markdown", + "id": "6610772d-7f3e-4a6e-9ebe-c5aefb526d58", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**References:**\n- [Buffer Documentation](https://buffer.com/developers/api/overview)\n- [Buffer API](https://buffer.com/developers/api/overview)" + ] + }, + { + "cell_type": "markdown", + "id": "1fe9adf6-25ef-49c9-82a7-ac2838d609c6", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "757da3e9-1905-40d1-b9ca-a236e57e06f9", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "568f05a0-45e4-46a0-a3a8-624154b174f5", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": "import requests\nimport json", + "outputs": [] + }, + { + "cell_type": "markdown", + "id": "9a7282e2-c438-4429-813c-707a13b33361", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup variables\n- **access_token**: Access token for Buffer API. [Link to procedure](https://buffer.com/developers/api/overview)\n- **profile_id**: Profile ID of the account where the post will be created. [Link to procedure](https://buffer.com/developers/api/overview)\n- **text**: Text of the post." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f30d40d1-3821-41c5-8012-7e18f26c7749", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": "access_token = \"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "outputs": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} \ No newline at end of file From 6fb8ca8bb1fff7baf7c3a9222bc30f8d813849a1 Mon Sep 17 00:00:00 2001 From: Florent Ravenel Date: Tue, 10 Oct 2023 17:40:43 +0200 Subject: [PATCH 2/2] feat: create draft init notebook --- Buffer/Buffer_Create_draft.ipynb | 152 +++++++++++++++++++++++++++++-- 1 file changed, 142 insertions(+), 10 deletions(-) diff --git a/Buffer/Buffer_Create_draft.ipynb b/Buffer/Buffer_Create_draft.ipynb index cbcfb34454..7b40302ec9 100644 --- a/Buffer/Buffer_Create_draft.ipynb +++ b/Buffer/Buffer_Create_draft.ipynb @@ -41,7 +41,7 @@ "tags": [] }, "source": [ - "**Author:** [Firstname Lastname]()" + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" ] }, { @@ -63,7 +63,7 @@ "tags": [] }, "source": [ - "**Description:** This notebook creates a draft for Buffer, a social media platform. It is usefull for organizations to quickly create a post for their social media accounts." + "**Description:** This notebook creates a draft for a specific profile on Buffer." ] }, { @@ -74,7 +74,8 @@ "tags": [] }, "source": [ - "**References:**\n- [Buffer Documentation](https://buffer.com/developers/api/overview)\n- [Buffer API](https://buffer.com/developers/api/overview)" + "**References:**\n", + "- [Buffer - Publishing](https://publish.buffer.com/profile)" ] }, { @@ -107,8 +108,11 @@ "papermill": {}, "tags": [] }, - "source": "import requests\nimport json", - "outputs": [] + "outputs": [], + "source": [ + "import requests\n", + "import json" + ] }, { "cell_type": "markdown", @@ -118,19 +122,147 @@ "tags": [] }, "source": [ - "### Setup variables\n- **access_token**: Access token for Buffer API. [Link to procedure](https://buffer.com/developers/api/overview)\n- **profile_id**: Profile ID of the account where the post will be created. [Link to procedure](https://buffer.com/developers/api/overview)\n- **text**: Text of the post." + "### Setup variables\n", + "- `buffer_url`: This variable holds the URL of the specific Buffer profile where you want to create a new post. Example: \"https://publish.buffer.com/profile/xxxxxxxxxxx/tab/queue\"\n", + "- `text`: This variable contains the text content that you want to post on the Buffer profile. You can modify this string to change the content of the post.\n", + "- `cookie`: This variable is used to store the cookie information from your Buffer session. The `input()` function is used to prompt you to manually enter your cookie information. You need to inspect your Buffer session in your web browser and copy/paste your cookie into the prompt. The cookie is used for authentication and maintaining the session with Buffer." ] }, { "cell_type": "code", "execution_count": null, - "id": "f30d40d1-3821-41c5-8012-7e18f26c7749", + "id": "3b2dbfd6-2f88-4f80-a1d2-dbaf7750e37b", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "buffer_url = \"https://publish.buffer.com/profile/xxxxxxxxxxxxxx/tab/queue\"\n", + "text = \"My Draft\"\n", + "cookie = input(\"Inspect your Buffer and Copy/Paste your cookie:\")" + ] + }, + { + "cell_type": "markdown", + "id": "677bd198-f9df-44e5-98d1-7243ce97ed25", "metadata": { "papermill": {}, "tags": [] }, - "source": "access_token = \"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - "outputs": [] + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "e17e49b3-ec98-4ebb-831f-ade9ef8951e0", + "metadata": {}, + "source": [ + "### Parse cookies" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e356d2ed-3755-4682-9444-bb345aaa3e26", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "def parse_cookie(cookie):\n", + " data = {}\n", + " for c in cookie.split(\";\"):\n", + " key = c.split(\"=\", 1)[0].strip()\n", + " value = c.split(\"=\", 1)[-1].strip()\n", + " data[key] = value\n", + " return data\n", + "\n", + "cookies = parse_cookie(cookie)" + ] + }, + { + "cell_type": "markdown", + "id": "2c979314-482d-4ead-94fa-b2c001637ca8", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "3daa3956-b58a-476f-81ba-c3f3a35ece4c", + "metadata": {}, + "source": [ + "### Create draft" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7a31b1a2-e325-4943-9d14-23429e63b224", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "def create_draft(buffer_url, cookies, text):\n", + " # Init\n", + " result = None\n", + " profile_id = buffer_url.split(\"/profile/\")[-1].split(\"/\")[0]\n", + " \n", + " # Base URL\n", + " url = 'https://publish.buffer.com/rpc/composerApiProxy'\n", + " \n", + " # Headers\n", + " headers = {\n", + " 'authority': 'publish.buffer.com',\n", + " 'accept': 'application/json',\n", + " 'accept-language': 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7',\n", + " 'content-type': 'application/json',\n", + " }\n", + "\n", + " args = {\n", + " \"url\": \"/1/updates/create.json\",\n", + " \"args\": {\n", + " \"now\": False,\n", + " \"top\": False,\n", + " \"is_draft\": True,\n", + " \"shorten\": True,\n", + " \"text\": text,\n", + " \"scheduling_type\": \"direct\",\n", + " \"fb_text\": \"\",\n", + " \"entities\": None,\n", + " \"annotations\": [],\n", + " \"profile_ids\": [profile_id],\n", + " \"attachment\": False,\n", + " \"via\": None,\n", + " \"source\": None,\n", + " \"version\": None,\n", + " \"created_source\": \"queue\",\n", + " \"channel_data\": None\n", + " },\n", + " \"HTTPMethod\": \"POST\"\n", + " }\n", + "\n", + " data = {\n", + " \"args\": json.dumps(args) # Convert the inner dictionary to a string\n", + " }\n", + " res = requests.post(url, headers=headers, data=json.dumps(data), cookies=cookies)\n", + " res.raise_for_status\n", + " if res.status_code == 200:\n", + " result = res.json().get(\"result\")\n", + " else:\n", + " print(response.status_code)\n", + " print(response.text)\n", + " return result\n", + "\n", + "result = create_draft(buffer_url, cookies, text)\n", + "result" + ] } ], "metadata": { @@ -161,4 +293,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} \ No newline at end of file +}