# Like Post for Linkedin (`addeus/like-post`) Actor

Automate engagement on LinkedIn by reacting to specific posts. Supports all reaction types (Like, Celebrate, Love, Insightful, etc.) to mimic human behavior. Uses Playwright and residential proxies for a secure and stealthy execution.

- **URL**: https://apify.com/addeus/like-post.md
- **Developed by:** [Addeus](https://apify.com/addeus) (community)
- **Categories:** Social media, Automation, Agents
- **Stats:** 5 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.005 / actor start

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## LinkedIn Like Post Actor

**Version 2.0.0** - Un actor Apify puissant qui automatise le like de posts LinkedIn en utilisant Puppeteer pour une simulation complète du comportement utilisateur.

### Fonctionnalités

- **Like automatique** de n'importe quel post LinkedIn via son URL
- **Authentification par cookies** (li_at) - pas besoin d'OAuth
- **Détection intelligente** du bouton like avec 7 stratégies différentes
- **Vérification automatique** si le post est déjà liké
- **Screenshots automatiques** pour debug (avant, après, et en cas d'erreur)
- **Anti-détection** - masque les flags webdriver pour éviter la détection
- **Logs détaillés** avec emojis pour un suivi facile
- **Gestion d'erreurs robuste** avec retry et fallback

### Input Parameters

| Paramètre    | Type   | Requis | Description                                                 |
| ------------ | ------ | ------ | ----------------------------------------------------------- |
| `postUrl`    | String | ✅ Oui | L'URL complète du post LinkedIn à liker                     |
| `liAtCookie` | String | ✅ Oui | Cookie d'authentification LinkedIn (li_at)                  |
| `userAgent`  | String | ❌ Non | User-Agent personnalisé (défaut: Chrome 131 Windows)        |
| `jsessionid` | String | ❌ Non | Cookie JSESSIONID optionnel pour authentification renforcée |

#### Exemple d'Input

```json
{
    "postUrl": "https://www.linkedin.com/feed/update/urn:li:activity:7251234567890123456",
    "liAtCookie": "AQEDATxxxxxx...",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
}
```

### Comment Obtenir Vos Cookies

#### Cookie li_at (REQUIS)

1. Ouvre ton navigateur et connecte-toi sur LinkedIn
2. Ouvre les DevTools (F12 ou Cmd+Option+I sur Mac)
3. Va dans l'onglet **Application** (Chrome) ou **Storage** (Firefox)
4. Navigue vers **Cookies** → **https://www.linkedin.com**
5. Trouve le cookie nommé `li_at`
6. Copie sa **valeur complète** (commence généralement par "AQEDAT")

#### Cookie JSESSIONID (OPTIONNEL)

1. Même procédure que pour li_at
2. Trouve le cookie nommé `JSESSIONID`
3. Copie sa valeur (commence généralement par "ajax:")

#### User-Agent (OPTIONNEL)

1. Ouvre la Console dans les DevTools (F12)
2. Tape: `navigator.userAgent`
3. Appuie sur Entrée et copie le résultat

### Output

L'actor sauvegarde les données suivantes dans le dataset:

```json
{
    "postUrl": "https://www.linkedin.com/feed/update/urn:li:activity:1234567890",
    "success": true,
    "message": "Successfully liked the post",
    "alreadyLiked": false,
    "timestamp": "2025-10-16T14:30:00.000Z",
    "details": {
        "strategy": "Aria Label - React Like",
        "verified": true
    }
}
```

#### Screenshots

L'actor prend automatiquement des screenshots sauvegardés dans le Key-Value Store:

- `screenshot-before-like`: Avant l'action de like
- `screenshot-after-like`: Après l'action réussie
- `screenshot-error`: En cas d'erreur (pour debug)
- `screenshot-not-logged-in`: Si l'authentification échoue

### Formats d'URL Supportés

L'actor supporte tous les formats d'URL LinkedIn:

- `https://www.linkedin.com/feed/update/urn:li:activity:1234567890`
- `https://www.linkedin.com/posts/username_activity-1234567890-abcd`
- `https://linkedin.com/feed/update/...` (sans www)

### Architecture Technique

#### Stratégies de Détection du Bouton Like

L'actor utilise **7 stratégies différentes** pour trouver le bouton like:

1. **Aria Label - React Like**: `button[aria-label*="React Like"]`
2. **Aria Label - Like**: `button[aria-label*="Like"]`
3. **Class - react-button__trigger**: `.react-button__trigger`
4. **Class - reactions-react-button**: `.reactions-react-button`
5. **Data Control - like_toggle**: `[data-control-name="like_toggle"]`
6. **Social Actions Button**: `.social-actions-button[aria-pressed="false"]`
7. **Any Like Button**: `button[aria-label*="like" i]` (case insensitive)

#### Anti-Détection

Le bot utilise plusieurs techniques pour éviter la détection:

- Masquage du flag `navigator.webdriver`
- User-Agent réaliste
- Viewport 1920x1080
- Cookies authentiques
- Attente de network idle
- Délais naturels entre actions

#### Workflow

1. **Lancement du browser** Puppeteer en mode headless
2. **Configuration** viewport, user-agent, cookies
3. **Navigation** vers l'URL du post
4. **Vérification** de l'authentification
5. **Détection** du bouton like avec stratégies multiples
6. **Click** sur le bouton
7. **Vérification** que le like est enregistré (aria-pressed=true)
8. **Screenshots** et logs détaillés
9. **Sauvegarde** du résultat dans le dataset

### Notes Importantes

#### Sécurité & Authentification

- Le cookie `li_at` est ta session LinkedIn - **garde-le secret**
- Les cookies expirent après un certain temps (renouvelle-les si erreur)
- Utiliser des cookies d'un appareil sur un autre peut déclencher des alertes

#### Rate Limiting

- LinkedIn peut limiter ou bloquer les actions automatisées trop fréquentes
- Recommandé: ajouter des délais entre plusieurs opérations de like
- Utilise avec modération pour éviter les restrictions de compte

#### Légal & CGU

- Cet actor est à des fins **éducatives et de test**
- L'automatisation peut violer les CGU de LinkedIn
- **Utilise à tes propres risques**
- Respecte toujours les politiques d'utilisation de LinkedIn

### Gestion des Erreurs

L'actor gère automatiquement:

- ❌ URL invalide ou inaccessible
- ❌ Échec d'authentification (cookie expiré)
- ❌ Bouton like introuvable
- ❌ Erreurs réseau et timeouts
- ❌ Post déjà liké (pas une erreur, juste un skip)

Tous les cas sont loggés avec détails et un screenshot est pris pour debug.

### Développement Local

#### Installation

```bash
cd like-post
npm install
```

#### Test Local

Crée un fichier `input.json` à la racine:

```json
{
    "postUrl": "https://www.linkedin.com/feed/update/urn:li:activity:YOUR_POST_ID",
    "liAtCookie": "YOUR_LI_AT_COOKIE"
}
```

Puis lance:

```bash
npm start
```

#### Structure du Projet

```
like-post/
├── .actor/
│   ├── actor.json          # Configuration de l'actor
│   └── input_schema.json   # Schéma des paramètres d'entrée
├── src/
│   └── main.js             # Code principal (v2.0)
├── package.json            # Dépendances Node.js
├── Dockerfile              # Configuration Docker
└── README.md               # Documentation
```

### Dépendances

- **Apify SDK** v3.1.0+ - Framework pour actors
- **Puppeteer** v24.0.0+ - Automation du navigateur Chrome
- **Node.js** 20.0.0+ - Runtime

### Troubleshooting

#### "Not logged in" Error

- ✅ Vérifie que ton cookie `li_at` est valide et complet
- ✅ Teste dans un navigateur en mode incognito avec le cookie
- ✅ Regarde le screenshot `screenshot-not-logged-in` pour debug

#### "Like button not found"

- ✅ Vérifie que l'URL du post est correcte et accessible
- ✅ Consulte le screenshot `screenshot-error` pour voir la page
- ✅ Le post existe peut-être plus ou est privé

#### "Failed to load page"

- ✅ Vérifie ta connexion internet
- ✅ L'URL peut être invalide ou le post supprimé
- ✅ LinkedIn peut bloquer l'accès (try again later)

### Changelog

#### Version 2.0.0 (Actuelle)

- ✨ Refonte complète du code avec architecture modulaire
- ✨ 7 stratégies de détection du bouton like
- ✨ Screenshots automatiques pour debug
- ✨ Anti-détection améliorée
- ✨ Vérification post-like (aria-pressed)
- ✨ Support cookie JSESSIONID optionnel
- ✨ Logs avec emojis et meilleure lisibilité
- ✨ Gestion d'erreurs robuste avec stack traces

#### Version 1.0.0

- 🎉 Version initiale avec Puppeteer

### License

ISC

### Disclaimer

Cet outil est fourni "tel quel" à des fins éducatives. Les auteurs ne sont pas responsables de toute mauvaise utilisation ou violation des CGU de LinkedIn. Les utilisateurs sont seuls responsables de s'assurer que leur utilisation est conforme aux lois applicables et aux conditions d'utilisation.

***

**Créé avec ❤️ pour Apify**

# Actor input Schema

## `postUrl` (type: `string`):

The full URL of the LinkedIn post you want to like/unlike (e.g., https://www.linkedin.com/feed/update/urn:li:activity:1234567890)

## `action` (type: `string`):

Action to perform: 'like' to like the post, 'unlike' to unlike it

## `liAtCookie` (type: `string`):

Your LinkedIn authentication cookie (li_at). You can find it in your browser's cookies for linkedin.com

## `userAgent` (type: `string`):

The User-Agent string to use (REQUIRED)

## Actor input object example

```json
{
  "postUrl": "https://www.linkedin.com/feed/update/urn:li:activity:1234567890",
  "action": "like",
  "liAtCookie": "AQEDATxxxxxx...",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("addeus/like-post").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("addeus/like-post").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call addeus/like-post --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,addeus/like-post"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/bRsja6L4PFu7nwHal/builds/9Jc9QG9GmEx0xFQYK/openapi.json
