Notion利用 Webhook 转换 X (Twitter) 图片地址
在国内访问 X (Twitter) 时,经常会遇到图片无法加载的问题。本文将介绍如何利用 Notion Pro 版本的 Webhook 功能,将 X 上的图片地址自动转换为全域可访问的图床地址。
Notion Pro 版本利用 Webhook 转换 X (Twitter) 图片地址
在国内访问 X (Twitter) 时,经常会遇到图片无法加载的问题。本文将介绍如何利用 Notion Pro 版本的 Webhook 功能,将 X 上的图片地址自动转换为全域可访问的图床地址。
方案概述
本方案的核心思路是:
准备工作
1. 创建 Notion 数据库
首先需要创建一个数据库,包含以下属性:
2. 开通 Notion Pro 版本或教育版本
3. 准备图床服务
选择一个稳定的图床服务,例如:我是自建CF图床服务器
4. 准备webhook 地址
用 zeabur免费搭建一个 n8n,复制下面的json,粘贴, 详见 n8n
markdown:
{
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "notion",
"responseMode": "responseNode",
"options": {}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2.1,
"position": [
-1200,
-208
],
"id": "8e6686cd-27e9-4ff0-9f28-750ad11ac061",
"name": "Webhook",
"webhookId": "4ec1ee48-86ad-4f6c-bbe3-79e62de4556f"
},
{
"parameters": {
"operation": "upload",
"bucketName": "myr2",
"fileName": "=x2r2/{{ $json.fname }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.s3",
"typeVersion": 1,
"position": [
-560,
-208
],
"id": "92ad2222-ebb5-4c8f-bfe4-c29c66194503",
"name": "Upload a file",
"credentials": {
"s3": {
"id": "ncud0cNG7cGuplHn",
"name": "R2"
}
}
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={\n \"url\": \"https://r2.51xmi.com/x2r2/{{ $('HTTP Request1').item.json.fname }}\"\n}",
"options": {}
},
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.5,
"position": [
-400,
-208
],
"id": "2c467480-4d30-4760-9168-bfb603268504",
"name": "Respond to Webhook"
},
{
"parameters": {
"fieldToSplitOut": "body.data.properties.xpic.title[0].text.content",
"options": {}
},
"type": "n8n-nodes-base.splitOut",
"typeVersion": 1,
"position": [
-992,
-208
],
"id": "fed0470b-5e34-4e00-91de-c86202ae59ff",
"name": "Split Out"
},
{
"parameters": {
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n item.json.fnow=$now.toMillis();\n item.json.fname =$('Webhook').first().json.body.data.properties.xpic.title[0].text.content.substring(28);\n}\n\nreturn $input.all();"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-848,
-208
],
"id": "f80f9afc-1cf6-48e2-b585-ed41bc4548cc",
"name": "Code in JavaScript"
},
{
"parameters": {
"url": "={{ $json[\"body.data.properties.xpic.title[0].text.content\"] }}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.3,
"position": [
-704,
-208
],
"id": "68ad8b6c-cd07-4fc7-b672-bb027b96e5c7",
"name": "HTTP Request1"
}
],
"connections": {
"Webhook": {
"main": [
[
{
"node": "Split Out",
"type": "main",
"index": 0
}
]
]
},
"Upload a file": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
},
"Split Out": {
"main": [
[
{
"node": "Code in JavaScript",
"type": "main",
"index": 0
}
]
]
},
"Code in JavaScript": {
"main": [
[
{
"node": "HTTP Request1",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request1": {
"main": [
[
{
"node": "Upload a file",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "9a76f2a1ba6fdea4ff2c5996f5a3abc25f5d8859ce9fff5f33d139fabc471b0e"
}
}配置 Webhook添加按钮触发
如果您希望手动控制转换时机,可以:
总结
通过 Notion Pro 的 Webhook 功能,我们可以轻松实现 X 图片地址的自动转换。这不仅解决了国内访问 X 图片的问题,还为其他自动化场景提供了思路。您可以根据实际需求,扩展更多功能,如支持其他平台的图片、添加水印等。
希望这篇教程能帮助您更好地使用 Notion 进行内容管理! 🚀


