Publication automatique sur Instagram et Facebook avec l'API Meta Graph et les jetons utilisateurs
Ceci est unSocial Mediaworkflow d'automatisation du domainecontenant 22 nœuds.Utilise principalement des nœuds comme Code, Wait, HttpRequest, ManualTrigger, ScheduleTrigger. Automatiser la publication sur Instagram et Facebook avec l'API Graph Meta et des jetons d'utilisateur système
- •Peut nécessiter les informations d'identification d'authentification de l'API cible
Nœuds utilisés (22)
Catégorie
{
"meta": {
"instanceId": "805a1da4490c39f62729f8489b312a775cb04286f77152b4febdc1f1642e5967",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "4fccdc64-1eb2-43a6-82c5-5ebcea2b801b",
"name": "Lors du clic sur 'Exécuter le workflow'",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-560,
480
],
"parameters": {},
"typeVersion": 1
},
{
"id": "738fabc1-5282-442b-a275-a3943bff890e",
"name": "Publier sur Instagram",
"type": "n8n-nodes-base.httpRequest",
"position": [
-300,
480
],
"parameters": {
"url": "https://graph.facebook.com/v19.0/<YOUR PAGE ID HERE>/media",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "form-urlencoded",
"authentication": "predefinedCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "image_url",
"value": "<YOUR IMAGE URL HERE>"
},
{
"name": "caption",
"value": "<YOUR CAPTION HERE>"
}
]
},
"nodeCredentialType": "facebookGraphApi"
},
"credentials": {
"facebookGraphApi": {
"id": "szDaIQHhZqLlJHII",
"name": "Facebook Graph account"
}
},
"typeVersion": 4.2
},
{
"id": "da899479-cfaa-4771-bc31-bdb0d4e4a3b7",
"name": "Publier le post instagram",
"type": "n8n-nodes-base.httpRequest",
"position": [
100,
480
],
"parameters": {
"url": "https://graph.facebook.com/v19.0/17841404935066235/media_publish",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "form-urlencoded",
"authentication": "predefinedCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "creation_id",
"value": "={{ $json.id }}"
}
]
},
"nodeCredentialType": "facebookGraphApi"
},
"credentials": {
"facebookGraphApi": {
"id": "szDaIQHhZqLlJHII",
"name": "Facebook Graph account"
}
},
"typeVersion": 4.2
},
{
"id": "b6cd01bd-f98f-4092-81f2-1b8f6e6c4b27",
"name": "Note adhésive",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1320,
-300
],
"parameters": {
"width": 540,
"height": 1900,
"content": "**How to Generate a Facebook Short-Lived Access Token for Instagram + Facebook Page Posting**\n\n### What You Need\n\n* A **Facebook account**\n* A **Facebook Page** (must be linked to an Instagram Business account if you plan to post to IG)\n* Access to [Meta for Developers](https://developers.facebook.com/)\n\n---\nStep-by-Step: How to Generate Your Short-Lived Token\n\n#### 1. Go to Meta for Developers\n\n* Visit: [https://developers.facebook.com/apps](https://developers.facebook.com/apps)\n* Log in with your Facebook credentials\n\n#### 2. Create a New App\n\n* Click the blue **Create App** button\n* Choose **Other** as the app type\n* On the next screen, select **Business**\n* Enter an app name and contact email, then click **Create App**\n\n#### 3. Open the App Dashboard\n\n* After creation, you’ll be redirected to the app’s dashboard\n* This is where you’ll manage products, permissions, and tokens\n\n#### 4. Add Products\n\n* In the left sidebar, scroll down to **Add Product**\n* Click **Set Up** on both:\n\n * **Instagram Graph API**\n * **Facebook Graph API** (If missing it is automatically setup when you create the app) \n\n> If you do not see the \"Add Product\" section, your app may already be locked to a specific template or be in Live mode. You can still continue to the Graph API Explorer.\n\n#### 5. Go to the Graph API Explorer\n\n* Visit: [https://developers.facebook.com/tools/explorer/](https://developers.facebook.com/tools/explorer/)\n* In the top-right dropdown, select your app\n* Under \"User or Page\", keep **User Token** selected\n\n#### 6. Generate a User Access Token\n\n* Click **Get Token** > **Get User Access Token**\n* A permissions dialog will appear\n\n#### 7. Select the Required Permissions (Scopes)\n\nCheck the following boxes:\n\n* `pages_show_list`\n* `pages_read_engagement`\n* `pages_manage_posts`\n* `instagram_basic`\n* `instagram_content_publish`\n\n> These allow you to post to both Facebook Pages and Instagram accounts. Some may require approval for production use.\n\n#### 8. Authenticate and Authorize\n\n* A pop-up will prompt you to log into Facebook and approve the app\n* Be sure to authorize access to your Facebook Page and linked Instagram account\n\n#### 9. Copy the Short-Lived Token\n\n* After successful login, the Graph API Explorer will refresh\n* Your new **short-lived token** will appear in the top bar\n* **Copy it immediately** — this token is valid for 1–2 hours\n\n"
},
"typeVersion": 1
},
{
"id": "fe0a05a4-5e13-4109-86c1-1da8fc5e7a9a",
"name": "Note adhésive 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-720,
-300
],
"parameters": {
"width": 1460,
"height": 540,
"content": "Facebook will only give you a \"Long Live Token\" if you are verified. If you are testing or not verified you can use the below method.\nThe initial token will only last a few hours, you can use the below to get the one that last for 2 months. Once you have the 2 month token you can put it in here and set the schedule to run every 30-60 days which will refresh and be saved in the static data.\n\n\n##Please note static Data does not run on a test, you can use a form submitted node to activate the flow.\n##Please note this is just a work around for testing and not practical for permanent use. "
},
"typeVersion": 1
},
{
"id": "cce6d146-599e-439a-bff6-fc0870a8df02",
"name": "Actualiser le jeton",
"type": "n8n-nodes-base.httpRequest",
"position": [
-300,
-120
],
"parameters": {
"url": "https://graph.facebook.com/v19.0/oauth/access_token",
"options": {},
"sendQuery": true,
"authentication": "predefinedCredentialType",
"queryParameters": {
"parameters": [
{
"name": "grant_type",
"value": "fb_exchange_token"
},
{
"name": "client_id",
"value": "<Your Client ID>"
},
{
"name": "client_secret",
"value": "<Your Secret Here>"
},
{
"name": "fb_exchange_token",
"value": "<your short token>"
}
]
},
"nodeCredentialType": "facebookGraphApi"
},
"credentials": {
"facebookGraphApi": {
"id": "szDaIQHhZqLlJHII",
"name": "Facebook Graph account"
}
},
"typeVersion": 4.2
},
{
"id": "e93d120b-ef7b-491c-bfcf-3d6a1ec62786",
"name": "Déclencheur planifié",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-680,
-120
],
"parameters": {
"rule": {
"interval": [
{
"daysInterval": 30,
"triggerAtHour": 1
}
]
}
},
"typeVersion": 1.2
},
{
"id": "097bde34-8787-4e0d-9dec-90f2de9c0aa1",
"name": "Obtenir le jeton actuel",
"type": "n8n-nodes-base.code",
"position": [
-500,
-120
],
"parameters": {
"jsCode": "const staticData = $getWorkflowStaticData('global');\nreturn [{\n json: {\n token: staticData.fb_token\n }\n}];\n"
},
"typeVersion": 2
},
{
"id": "75f115f5-eee8-4e85-bd35-8c70ac4c13c5",
"name": "Envoyer vers données statiques",
"type": "n8n-nodes-base.code",
"position": [
-80,
-120
],
"parameters": {
"jsCode": "const staticData = $getWorkflowStaticData('global');\nstaticData.fb_token = $json.access_token;\n\nreturn [{\n json: {\n status: 'Token saved to static data',\n token: staticData.fb_token\n }\n}];\n"
},
"typeVersion": 2
},
{
"id": "95439d8f-c568-497a-901f-69b2cfd7172f",
"name": "Obtenir le jeton depuis données statiques",
"type": "n8n-nodes-base.code",
"position": [
-640,
60
],
"parameters": {
"jsCode": "const staticData = $getWorkflowStaticData('global');\nreturn [{\n json: {\n token: staticData.fb_token\n }\n}];\n"
},
"typeVersion": 2
},
{
"id": "b13db71d-0620-46d4-a9f9-17b693930af4",
"name": "Publier sur Instagram 1",
"type": "n8n-nodes-base.httpRequest",
"position": [
-420,
60
],
"parameters": {
"url": "https://graph.facebook.com/v19.0/<Instagram Page ID>/media",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "form-urlencoded",
"bodyParameters": {
"parameters": [
{
"name": "image_url",
"value": "<Your Image Url>"
},
{
"name": "caption",
"value": "<Your Caption>"
},
{
"name": "access_token",
"value": "={{ $json.token }}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "72bb812b-7ccf-4703-8d6d-35feb3576792",
"name": "Publier le post instagram 1",
"type": "n8n-nodes-base.httpRequest",
"position": [
-60,
60
],
"parameters": {
"url": "https://graph.facebook.com/v19.0/<your instagram page id>/media_publish",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "form-urlencoded",
"bodyParameters": {
"parameters": [
{
"name": "creation_id",
"value": "={{ $json.id }}"
},
{
"name": "access_token",
"value": "={{ $('Get Token from static Data').item.json.token }}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "5a279b05-d40f-47b6-a7f1-56daa21ff773",
"name": "Publier sur Facebook",
"type": "n8n-nodes-base.httpRequest",
"position": [
780,
480
],
"parameters": {
"url": "https://graph.facebook.com/v19.0/266271423823110/photos",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "form-urlencoded",
"authentication": "predefinedCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "url",
"value": "https://images.pexels.com/photos/5475816/pexels-photo-5475816.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=627&w=1200"
},
{
"name": "caption",
"value": "This is the caption for the post"
},
{
"name": "access_token",
"value": "={{ $json.data[0].access_token }}"
}
]
},
"nodeCredentialType": "facebookGraphApi"
},
"credentials": {
"facebookGraphApi": {
"id": "szDaIQHhZqLlJHII",
"name": "Facebook Graph account"
}
},
"typeVersion": 4.2
},
{
"id": "395e1149-cb03-45f3-97b1-1a5fe8e4ac06",
"name": "Utiliser le jeton système pour obtenir un jeton de page",
"type": "n8n-nodes-base.httpRequest",
"position": [
320,
480
],
"parameters": {
"url": "https://graph.facebook.com/v19.0/me/accounts",
"options": {},
"authentication": "predefinedCredentialType",
"nodeCredentialType": "facebookGraphApi"
},
"credentials": {
"facebookGraphApi": {
"id": "szDaIQHhZqLlJHII",
"name": "Facebook Graph account"
}
},
"typeVersion": 4.2
},
{
"id": "926c9774-6e9b-427f-8916-3ccf4ce30012",
"name": "Note adhésive 3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-720,
340
],
"parameters": {
"color": 5,
"width": 1760,
"height": 360,
"content": "Using the permanant never expire token"
},
"typeVersion": 1
},
{
"id": "1ef57c3d-fc04-4107-82e3-3faf0dcfe2ce",
"name": "Note adhésive 4",
"type": "n8n-nodes-base.stickyNote",
"position": [
1080,
-80
],
"parameters": {
"width": 680,
"height": 1220,
"content": " How to Create a Permanent System User Token (Recommended)\n\nThis token doesn’t expire and is best for automation use cases\n\n1. Verify Your Business\n\nGo to https://business.facebook.com/settings/info\n\nComplete business verification under Business Info tab\n\nSubmit your business documents and wait for approval (Sometimes you just have to submit an EIN/Tax-ID.\n\nApproval can take 1-5 Business days\n\nOnce Approved do the following.\n\n2. Create a System User\n\nIn Business Settings\n\nGo to System Users > Click Add\n\nAssign a name (e.g. n8n-bot) and select Admin access\n\n3. Assign Assets to System User\n\nIn the same System User view, assign:\n\nYour Facebook Page (with Full Control)\n\nYour Instagram Account (linked via Page)\n\nYour App\n\n4. Generate a Token\n\nClick Generate Token\n\nSelect your App\n\nSet expiration to Never\n\nGrant these permissions:\n\npages_show_list\n\npages_read_engagement\n\npages_manage_posts\n\ninstagram_basic\n\ninstagram_content_publish\n\n-If instagram_content_publish is not visible, you may need to request it via App Review under the App dashboard.\n\n5. Use This Token\n\nStore it in the Facebook Graph API\n\n"
},
"typeVersion": 1
},
{
"id": "4eaa4823-7601-49d1-9cec-da232ac7ee62",
"name": "Obtenir le jeton de page correct",
"type": "n8n-nodes-base.code",
"position": [
560,
480
],
"parameters": {
"jsCode": "const page = $json.data.find(p => p.id === '266271423823110');\nreturn [{ json: { access_token: page.access_token } }];\n"
},
"typeVersion": 2
},
{
"id": "abb870c7-9241-4503-9fb1-348dcbf29dad",
"name": "Attendre 2 secondes",
"type": "n8n-nodes-base.wait",
"position": [
-120,
480
],
"webhookId": "c40b180e-016c-4648-898a-5942b8a9b00d",
"parameters": {
"amount": 2
},
"typeVersion": 1.1
},
{
"id": "70120c0d-d21a-4fa2-b8d5-81931c198c65",
"name": "Attendre 2 secondes 1",
"type": "n8n-nodes-base.wait",
"position": [
-240,
60
],
"webhookId": "c40b180e-016c-4648-898a-5942b8a9b00d",
"parameters": {
"amount": 2
},
"typeVersion": 1.1
},
{
"id": "4cde11f4-c12f-4827-94ce-9ee9d11d821d",
"name": "Utiliser le jeton système pour obtenir un jeton de page 1",
"type": "n8n-nodes-base.httpRequest",
"position": [
160,
60
],
"parameters": {
"url": "https://graph.facebook.com/v19.0/me/accounts",
"options": {},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "access_token",
"value": "={{ $('Get Token from static Data').item.json.token }}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "f7581a1c-d095-4fe9-951c-cc6b6108156a",
"name": "Obtenir le jeton de page correct 1",
"type": "n8n-nodes-base.code",
"position": [
380,
60
],
"parameters": {
"jsCode": "const page = $json.data.find(p => p.id === '<YOUR PAGE ID HERE>');\nreturn [{ json: { access_token: page.access_token } }];\n"
},
"typeVersion": 2
},
{
"id": "306bb9bb-5ba0-4ecd-96a8-33e3ec292526",
"name": "Publier sur Facebook 1",
"type": "n8n-nodes-base.httpRequest",
"position": [
580,
60
],
"parameters": {
"url": "https://graph.facebook.com/v19.0/<YOUR PAGE ID HERE>/photos",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "form-urlencoded",
"bodyParameters": {
"parameters": [
{
"name": "url",
"value": "<YOUR IMAGE URL HERE>"
},
{
"name": "caption",
"value": "<YOUR CAPTION HERE>"
},
{
"name": "access_token",
"value": "={{ $json.data[0].access_token }}"
}
]
}
},
"typeVersion": 4.2
}
],
"pinData": {},
"connections": {
"cce6d146-599e-439a-bff6-fc0870a8df02": {
"main": [
[
{
"node": "75f115f5-eee8-4e85-bd35-8c70ac4c13c5",
"type": "main",
"index": 0
}
]
]
},
"abb870c7-9241-4503-9fb1-348dcbf29dad": {
"main": [
[
{
"node": "da899479-cfaa-4771-bc31-bdb0d4e4a3b7",
"type": "main",
"index": 0
}
]
]
},
"70120c0d-d21a-4fa2-b8d5-81931c198c65": {
"main": [
[
{
"node": "72bb812b-7ccf-4703-8d6d-35feb3576792",
"type": "main",
"index": 0
}
]
]
},
"e93d120b-ef7b-491c-bfcf-3d6a1ec62786": {
"main": [
[
{
"node": "097bde34-8787-4e0d-9dec-90f2de9c0aa1",
"type": "main",
"index": 0
}
]
]
},
"097bde34-8787-4e0d-9dec-90f2de9c0aa1": {
"main": [
[
{
"node": "cce6d146-599e-439a-bff6-fc0870a8df02",
"type": "main",
"index": 0
}
]
]
},
"738fabc1-5282-442b-a275-a3943bff890e": {
"main": [
[
{
"node": "abb870c7-9241-4503-9fb1-348dcbf29dad",
"type": "main",
"index": 0
}
]
]
},
"b13db71d-0620-46d4-a9f9-17b693930af4": {
"main": [
[
{
"node": "70120c0d-d21a-4fa2-b8d5-81931c198c65",
"type": "main",
"index": 0
}
]
]
},
"4eaa4823-7601-49d1-9cec-da232ac7ee62": {
"main": [
[
{
"node": "5a279b05-d40f-47b6-a7f1-56daa21ff773",
"type": "main",
"index": 0
}
]
]
},
"da899479-cfaa-4771-bc31-bdb0d4e4a3b7": {
"main": [
[
{
"node": "395e1149-cb03-45f3-97b1-1a5fe8e4ac06",
"type": "main",
"index": 0
}
]
]
},
"f7581a1c-d095-4fe9-951c-cc6b6108156a": {
"main": [
[
{
"node": "306bb9bb-5ba0-4ecd-96a8-33e3ec292526",
"type": "main",
"index": 0
}
]
]
},
"72bb812b-7ccf-4703-8d6d-35feb3576792": {
"main": [
[
{
"node": "4cde11f4-c12f-4827-94ce-9ee9d11d821d",
"type": "main",
"index": 0
}
]
]
},
"95439d8f-c568-497a-901f-69b2cfd7172f": {
"main": [
[
{
"node": "b13db71d-0620-46d4-a9f9-17b693930af4",
"type": "main",
"index": 0
}
]
]
},
"395e1149-cb03-45f3-97b1-1a5fe8e4ac06": {
"main": [
[
{
"node": "4eaa4823-7601-49d1-9cec-da232ac7ee62",
"type": "main",
"index": 0
}
]
]
},
"4cde11f4-c12f-4827-94ce-9ee9d11d821d": {
"main": [
[
{
"node": "f7581a1c-d095-4fe9-951c-cc6b6108156a",
"type": "main",
"index": 0
}
]
]
},
"4fccdc64-1eb2-43a6-82c5-5ebcea2b801b": {
"main": [
[
{
"node": "738fabc1-5282-442b-a275-a3943bff890e",
"type": "main",
"index": 0
}
]
]
}
}
}Comment utiliser ce workflow ?
Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.
Dans quelles scénarios ce workflow est-il adapté ?
Avancé - Réseaux sociaux
Est-ce payant ?
Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.
Workflows recommandés
Brian
@typebconsultingspecializing in automation, AI integrations, and workflow optimization. I build high-impact n8n workflows that connect Salesforce, Outlook, RingCentral, and more. Reach out if you need help making your systems talk to each other.
Partager ce workflow