Facebook 和 Instagram 续订令牌
中级
这是一个自动化工作流,包含 13 个节点。主要使用 If, Set, DataTable, HttpRequest, ManualTrigger 等节点。 使用 Graph API 和数据存储自动续订 Meta 令牌
前置要求
- •可能需要目标 API 的认证凭证
分类
-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "QRfOs6S3QrhslSFD",
"meta": {
"instanceId": "8e9162e70be518ca153a70a16d8785f5bfc6523821e135712fb7ef93fe97a5dd"
},
"name": "Facebook & Instagram 续订令牌",
"tags": [],
"nodes": [
{
"id": "56b6e307-f5e0-405e-9e1e-eb8e2d49b518",
"name": "计划触发器",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-304,
-80
],
"parameters": {
"rule": {
"interval": [
{
"daysInterval": 10,
"triggerAtHour": 21
}
]
}
},
"typeVersion": 1.2
},
{
"id": "3a4de69d-c1d8-4e83-b3bb-25e6ff1c3cd3",
"name": "无操作,不执行任何操作",
"type": "n8n-nodes-base.noOp",
"position": [
400,
160
],
"parameters": {},
"typeVersion": 1
},
{
"id": "ed641ba7-01ec-4baa-bf2e-5cac217a7709",
"name": "获取令牌过期日期",
"type": "n8n-nodes-base.dataTable",
"position": [
-32,
0
],
"parameters": {
"limit": 1,
"operation": "get",
"dataTableId": {
"__rl": true,
"mode": "list",
"value": "TcHt9QIGMyCs1qIB",
"cachedResultUrl": "/projects/XqoBcIeUrbWmIJt8/datatables/TcHt9QIGMyCs1qIB",
"cachedResultName": "Meta credential"
}
},
"typeVersion": 1
},
{
"id": "ebfac905-851e-42db-b4d4-5c2a67987b46",
"name": "需要续订?",
"type": "n8n-nodes-base.if",
"position": [
176,
0
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "e62d1e04-38f2-454f-9301-6b6b896a9e5a",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ new Date($json.expires_at) <= new Date(Date.now() + 15*24*60*60*1000) }}",
"rightValue": "={{ 10 }}"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "1da184df-364e-4c52-844a-f368480ad132",
"name": "携带 ID 和令牌",
"type": "n8n-nodes-base.set",
"position": [
400,
-16
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "1d09ed8a-2288-42db-b355-63e9b0354cbb",
"name": "record_id",
"type": "number",
"value": "={{ $json.id }}"
},
{
"id": "25975e2f-4375-41d4-b9cb-97ac0cec134b",
"name": "current_token",
"type": "string",
"value": "={{ $json.token }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "42726ba6-dbab-4cdc-893e-92c299c0fe96",
"name": "用户交换",
"type": "n8n-nodes-base.httpRequest",
"position": [
672,
-16
],
"parameters": {
"url": "https://graph.facebook.com/v20.0/oauth/access_token",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "form-urlencoded",
"bodyParameters": {
"parameters": [
{
"name": "grant_type",
"value": "fb_exchange_token"
},
{
"name": "client_id"
},
{
"name": "client_secret"
},
{
"name": "fb_exchange_token",
"value": "={{$json.current_token}}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "2e570311-fc11-408c-956a-f66a246aa5e1",
"name": "计算新过期时间",
"type": "n8n-nodes-base.set",
"position": [
960,
-16
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "6be317cc-adac-45eb-a36d-0440c0fbac1c",
"name": "token",
"type": "string",
"value": "={{ $json.access_token }}"
},
{
"id": "5d6562df-c638-4245-b967-c02e2617fab5",
"name": "expired_at",
"type": "string",
"value": "={{ new Date(Date.now() + ($json.expires_in)*1000).toISOString() }}"
},
{
"id": "3268497e-4040-4486-bde1-b65caf5141df",
"name": "record_id",
"type": "string",
"value": "={{ $node[\"Carry ID & Token\"].json.record_id }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "97cbffa5-4305-42da-bafe-26a5f06df25a",
"name": "更新记录",
"type": "n8n-nodes-base.dataTable",
"position": [
1168,
-16
],
"parameters": {
"columns": {
"value": {
"token": "={{$json.token}}",
"expires_at": "={{$json.expired_at}}"
},
"schema": [
{
"id": "token",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "token",
"defaultMatch": false
},
{
"id": "expires_at",
"type": "dateTime",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "expires_at",
"defaultMatch": false
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"filters": {
"conditions": [
{
"keyValue": "={{$json.record_id}}"
}
]
},
"operation": "update",
"dataTableId": {
"__rl": true,
"mode": "list",
"value": "TcHt9QIGMyCs1qIB",
"cachedResultUrl": "/projects/XqoBcIeUrbWmIJt8/datatables/TcHt9QIGMyCs1qIB",
"cachedResultName": "Meta credencial"
}
},
"typeVersion": 1
},
{
"id": "e477c855-2431-4507-a8bb-8f108ab5a973",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-416,
-240
],
"parameters": {
"width": 288,
"height": 480,
"content": "* 目前 cron 每 10 天运行一次,以避免消耗过多 n8n 积分。您可以随意更改。如果更改,请同时更改\"需要续订?\"节点中的逻辑。"
},
"typeVersion": 1
},
{
"id": "9e8f62b4-187d-43eb-a40b-baa555c01eb6",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-112,
-240
],
"parameters": {
"color": 4,
"width": 256,
"height": 480,
"content": "## 数据表"
},
"typeVersion": 1
},
{
"id": "6afeba73-f1f4-436d-a3a4-811cc6d841de",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
592,
-256
],
"parameters": {
"color": 5,
"width": 272,
"height": 496,
"content": "## 生成新令牌"
},
"typeVersion": 1
},
{
"id": "fef64b9c-a077-4278-9187-db0743ca7692",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
912,
-256
],
"parameters": {
"color": 2,
"width": 448,
"height": 496,
"content": "## 设置新过期日期并更新数据表"
},
"typeVersion": 1
},
{
"id": "2e41d7ee-aae9-4083-bdd0-4252fc764dd9",
"name": "当点击\"执行工作流\"时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-304,
80
],
"parameters": {},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"callerPolicy": "workflowsFromSameOwner",
"availableInMCP": false,
"executionOrder": "v1"
},
"versionId": "7be243a3-0f7d-4039-990a-613e2a856002",
"connections": {
"User Exchange": {
"main": [
[
{
"node": "Compute new expiry",
"type": "main",
"index": 0
}
]
]
},
"Needs renewal?": {
"main": [
[
{
"node": "Carry ID & Token",
"type": "main",
"index": 0
}
],
[
{
"node": "No Operation, do nothing",
"type": "main",
"index": 0
}
]
]
},
"Carry ID & Token": {
"main": [
[
{
"node": "User Exchange",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Get token expiration date",
"type": "main",
"index": 0
}
]
]
},
"Compute new expiry": {
"main": [
[
{
"node": "Update Record",
"type": "main",
"index": 0
}
]
]
},
"Get token expiration date": {
"main": [
[
{
"node": "Needs renewal?",
"type": "main",
"index": 0
}
]
]
},
"When clicking \"Execute workflow\"": {
"main": [
[
{
"node": "Get token expiration date",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Shopify博客内部链接
使用OpenAI text-embedding-3-small自动生成Shopify博客相关文章
If
Set
Code
+6
26 节点Geoffroy
内容创作
Shopify博客自动化:基于关键词列表的SEO/AEO优化文章
使用GPT-4和Google表格生成SEO/AEO优化的Shopify博客文章
If
Set
Code
+6
32 节点Geoffroy
内容创作
公共SEO - Google和Bing索引自动化
使用Google索引API和Bing IndexNow提交变更站点地图URL的工作流
If
Set
Xml
+9
28 节点Geoffroy
内容创作
监控Jamf策略完整性并发送Slack变更警报
监控Jamf策略完整性并在变更时发送Slack警报
If
Set
Xml
+10
23 节点Jean-Marie Rizkallah
用于处理Telegram媒体组的数据表
使用数据表缓存和NanoBanana AI处理Telegram图片相册
If
Set
Sort
+12
35 节点Eduard
内容创作
AI生成的WordPress文章摘要块
WordPress文章的AI生成摘要块
If
Set
Slack
+14
32 节点Dataki
人工智能