Schedule and publish LinkedIn posts from a
.docxfile via the official LinkedIn UGC Posts API. A small command-line helper that generates dated.docxdrafts, runs in the background, and posts them automatically when their scheduled time arrives.
A no-frills CLI to:
- generate a
.docxpost template named with the target publication date and time; - run a background watcher that, every hour, scans
scheduled_posts/and publishes any document whose timestamp falls within plus or minus one hour of now on LinkedIn; - test that your
ACCESS_TOKENandURNare valid.
The goal is to author posts in a familiar Word/LibreOffice editor instead of LinkedIn's web textarea, and to time-shift their publication.
git clone https://github.com/Tan-Software/automate-linkedin-posting.git
cd automate-linkedin-posting
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env # then fill in ACCESS_TOKEN and URN
python main.pyYou will be prompted to:
1— generate a new.docxdraft (you pick its publication date/time).2— launch the background scheduler (publishes drafts as their slot arrives).3— run a connectivity test against the LinkedIn API.
Variables are read from .env:
| Variable | Description |
|---|---|
ACCESS_TOKEN |
LinkedIn API access token (w_member_social scope) |
URN |
Member URN of the publishing account (the part after urn:li:person:) |
See LinkedIn's official guide for how to obtain a token.
automate-linkedin-posting/
├─ main.py # entry point and choice menu
├─ libs/
│ ├─ welcome.py # CLI prompt
│ ├─ generate_scheduled_post.py # produces a dated .docx in scheduled_posts/
│ └─ post_on_linkedin.py # background watcher + LinkedIn UGC publish
├─ requirements.txt
├─ .env.example
└─ ruff.toml
The repository ships a Ruff configuration and a GitHub Actions workflow that runs ruff check and ruff format --check on every push and pull request.
Local checks:
pip install ruff
ruff check .
ruff format --check .Un petit utilitaire en ligne de commande pour :
- générer un modèle
.docxnommé d après la date et l heure de publication souhaitée ; - lancer un superviseur en arrière-plan qui scrute
scheduled_posts/toutes les heures et publie sur LinkedIn les documents dont l horodatage tombe dans la fenêtre plus ou moins une heure ; - tester que
ACCESS_TOKENetURNfonctionnent.
L idée est de rédiger ses posts dans Word/LibreOffice plutôt que dans l éditeur web de LinkedIn, et d en différer la publication.
git clone https://github.com/Tan-Software/automate-linkedin-posting.git
cd automate-linkedin-posting
python -m venv .venv && source .venv/bin/activate # Windows : .venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env # puis renseignez ACCESS_TOKEN et URN
python main.pyTrois choix vous sont proposés :
1— générer un nouveau brouillon.docx(vous choisissez sa date/heure de publication).2— lancer le superviseur en arrière-plan (publie les brouillons à leur créneau).3— lancer un test de connexion à l API LinkedIn.
Distribué sous licence MIT.
Tansoftware - Tanguy Chénier · LinkedIn · Tan-Software · Compte personnel (derniers outils) · tansoftware.com