通过HttpRequest节点使用XMLRPC在Wordpress.com上发布
中级
这是一个Building Blocks, Marketing领域的自动化工作流,包含 11 个节点。主要使用 If, Set, Xml, Code, HttpRequest 等节点。 通过HTTP请求节点发布到XMLRPC API
前置要求
- •可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "yPIST7l13huQEjY5",
"meta": {
"instanceId": "98bf0d6aef1dd8b7a752798121440fb171bf7686b95727fd617f43452393daa3",
"templateCredsSetupCompleted": true
},
"name": "通过 HttpRequest 节点使用 XMLRPC 在 Wordpress.com 上发布",
"tags": [
{
"id": "uumvgGHY5e6zEL7V",
"name": "Published Template",
"createdAt": "2025-02-10T11:18:10.923Z",
"updatedAt": "2025-02-10T11:18:10.923Z"
}
],
"nodes": [
{
"id": "8a64ffca-804a-4793-a721-3cb670aec22f",
"name": "设置",
"type": "n8n-nodes-base.set",
"position": [
-380,
-700
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "1be018c7-51fe-4ea2-967d-ce47a2e8795c",
"name": "wordpressUrl",
"type": "string",
"value": "YOURBLOG.wordpress.com"
},
{
"id": "95377f4f-184b-46a7-94c7-b2313c314cb2",
"name": "wordpressUsername",
"type": "string",
"value": "YourUserName"
},
{
"id": "fdc99dc6-d9b0-4d2f-b770-1d8b6b360cad",
"name": "wordpressApplicationPassword",
"type": "string",
"value": "your 4app pass word"
},
{
"id": "5aee5eef-9ad2-4dfb-a63f-1b5228c47e31",
"name": "contentTitle",
"type": "string",
"value": "This is a demo title"
},
{
"id": "2abf516c-2910-4cd0-89fe-119cd0e616c8",
"name": "contentText",
"type": "string",
"value": "This is the main text."
}
]
}
},
"typeVersion": 3.4
},
{
"id": "157b9656-5d90-44f4-aa3c-1285cda698d8",
"name": "手动触发器",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-580,
-700
],
"parameters": {},
"typeVersion": 1
},
{
"id": "1d2f6916-e5bd-497b-9843-8bb5a48e9866",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-420,
-820
],
"parameters": {
"width": 180,
"height": 360,
"content": "## 设置"
},
"typeVersion": 1
},
{
"id": "1306446a-f628-44ba-9ca5-751b634bd5dd",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
140,
-820
],
"parameters": {
"color": 5,
"width": 720,
"height": 360,
"content": "## 响应处理"
},
"typeVersion": 1
},
{
"id": "ec3006aa-34c8-4522-8c37-980f68f168b5",
"name": "便利贴5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-220,
-820
],
"parameters": {
"color": 3,
"width": 340,
"height": 360,
"content": "## 请求发送"
},
"typeVersion": 1
},
{
"id": "bc918075-bea5-4a27-90d9-874b0917a958",
"name": "成功",
"type": "n8n-nodes-base.noOp",
"position": [
660,
-780
],
"parameters": {},
"typeVersion": 1
},
{
"id": "3ea541b7-080e-4694-b865-d7d04f69ea0c",
"name": "错误",
"type": "n8n-nodes-base.noOp",
"position": [
660,
-620
],
"parameters": {},
"typeVersion": 1
},
{
"id": "457c0687-ac1d-49e2-b434-6e1de9acb3a3",
"name": "准备XML",
"type": "n8n-nodes-base.code",
"notes": "(request payload, escaping)",
"position": [
-180,
-700
],
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const input = $json; // If other nodes are in between: $('Settings').item.json;\n\nconst username = input.wordpressUsername;\nconst password = input.wordpressApplicationPassword;\nconst title = input.contentTitle;\nconst text = input.contentText;\n\nconst blogId = 0;\nconst published = 1; // 0 = draft, 1 = published\n\n\n// Helper function to escape XML special characters\nfunction escapeXml(unsafe) {\n return unsafe.replace(/[<>&'\"]/g, (c) => {\n switch (c) {\n case '<': return '<';\n case '>': return '>';\n case '&': return '&';\n case '\\'': return ''';\n case '\"': return '"';\n default: return c;\n }\n });\n}\n\n// Your actual post text, which may contain characters needing escaping\nconst titleEscaped = escapeXml(title);\nconst textEscaped = escapeXml(text);\n\n// Build the XML payload\nconst xmlData = `<?xml version=\"1.0\"?>\n<methodCall>\n <methodName>wp.newPost</methodName>\n <params>\n <param>\n <value><string>${blogId}</string></value>\n </param>\n <param>\n <value><string>${username}</string></value>\n </param>\n <param>\n <value><string>${password}</string></value>\n </param>\n <param>\n <value>\n <struct>\n <member>\n <name>post_title</name>\n <value><string>${titleEscaped}</string></value>\n </member>\n <member>\n <name>post_content</name>\n <value><string>${textEscaped}</string></value>\n </member>\n </struct>\n </value>\n </param>\n <param>\n <value><boolean>${published}</boolean></value>\n </param>\n </params>\n</methodCall>`;\n\n\n// Add a new field called 'myNewField' to the JSON of the item\n$input.item.json.xmlRequestBody = xmlData;\n\nreturn $input.item;"
},
"notesInFlow": true,
"typeVersion": 2
},
{
"id": "3f29f3ed-f7ae-475b-bce3-04d3eeeacee9",
"name": "发送请求",
"type": "n8n-nodes-base.httpRequest",
"position": [
-20,
-700
],
"parameters": {
"url": "=https://{{ $('Settings').item.json.wordpressUrl }}/xmlrpc.php",
"body": "={{ $json.xmlRequestBody }}",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "raw",
"sendHeaders": true,
"rawContentType": "text/xml",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "text/xml"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "5f320d9b-8aa9-4d13-83db-86acaf444e92",
"name": "是否成功",
"type": "n8n-nodes-base.if",
"position": [
420,
-700
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "loose"
},
"combinator": "and",
"conditions": [
{
"id": "815d85a1-8f91-4338-977f-503f02c53ea2",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.methodResponse.params.param.value }}",
"rightValue": ""
}
]
},
"looseTypeValidation": true
},
"typeVersion": 2.2
},
{
"id": "3a37d19a-12d3-474b-840f-c09342eecca9",
"name": "处理响应",
"type": "n8n-nodes-base.xml",
"position": [
220,
-700
],
"parameters": {
"options": {}
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "78f90dc5-6209-4db0-b6c6-9f2324488605",
"connections": {
"Settings": {
"main": [
[
{
"node": "PrepareXML",
"type": "main",
"index": 0
}
]
]
},
"PrepareXML": {
"main": [
[
{
"node": "PostRequest",
"type": "main",
"index": 0
}
]
]
},
"PostRequest": {
"main": [
[
{
"node": "HandleResponse",
"type": "main",
"index": 0
}
]
]
},
"IsSuccessful": {
"main": [
[
{
"node": "Success",
"type": "main",
"index": 0
}
],
[
{
"node": "Error",
"type": "main",
"index": 0
}
]
]
},
"ManualTrigger": {
"main": [
[
{
"node": "Settings",
"type": "main",
"index": 0
}
]
]
},
"HandleResponse": {
"main": [
[
{
"node": "IsSuccessful",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 构建模块, 营销
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
博客自动化模板
从Google表格撰写和发布博客文章
If
Set
Code
+7
35 节点Daniel Nolde
人工智能
我的工作流2
提取Google Trends关键词并在Google Sheets中总结文章
If
Set
Xml
+8
26 节点Miko
营销
[模板] AI宠物店 v8
🐶 AI宠物店助手 - 集成GPT-4o、Google日历和WhatsApp/Instagram/Facebook
If
N8n
Set
+38
244 节点Amanda Benks
销售
Overpass 潜在客户生成系统
使用 OpenStreetMap 数据生成商业线索并保存到 Google Sheets
If
Set
Code
+12
27 节点Akram Kadri
销售
(Duc)深度研究市场模板
集成PerplexityAI研究和OpenAI内容的多层级WordPress博客生成器
If
Set
Xml
+28
132 节点Daniel Ng
人工智能
并行子工作流执行后等待全部完成模式
并行子工作流执行后等待全部完成模式
If
Set
Code
+8
18 节点Hubschrauber
其他