Overview
This node provides three main operations related to PHP serialization and WeChat messaging:
- PHP Serialization: Converts JSON data into a PHP serialized string. Useful when you need to send or store data in a format compatible with PHP applications.
- PHP Unserialization: Converts a PHP serialized string back into JSON, optionally extracting a nested field by path. This helps integrate PHP-generated data into workflows that use JSON.
- WeChat Broadcast: Sends messages (text or image) to a specified WeChat contact or group chat. It supports using an already logged-in WeChat account or logging in dynamically via QR code scanning.
Practical Examples
- Serialize complex JSON objects into PHP serialized strings for API requests to PHP backend systems.
- Unserialize PHP serialized responses from legacy PHP services and extract specific fields for further processing.
- Automate sending notifications or images to WeChat groups or contacts directly from n8n workflows.
Properties
Name | Meaning |
---|---|
操作 (operation) | Choose the operation: "PHP 反序列化" (unserialize), "PHP 序列化" (serialize), or "微信群发" (wechatBroadcast). |
PHP 序列化字符串 | The PHP serialized string to unserialize (only shown if operation is "unserialize"). |
JSON 数据 | JSON data to serialize into PHP format (only shown if operation is "serialize"). |
提取字段路径 (extractPath) | Optional dot-separated path to extract a nested field from the unserialized result (only for "unserialize"). Example: pay_download.0.link . |
使用已登录的微信账号 | Boolean to indicate whether to use an already logged-in WeChat account (only for "wechatBroadcast"). |
消息类型 (messageType) | Type of message to send: "文本消息" (text) or "图片消息" (image) (only for "wechatBroadcast"). |
消息内容 (messageContent) | Text content of the message to send (only for text messages in "wechatBroadcast"). |
图片URL (imageUrl) | URL of the image to send (only for image messages in "wechatBroadcast"). |
接收者类型 (recipientType) | Recipient type: "群聊" (room) or "好友" (contact) (only for "wechatBroadcast"). |
接收者名称 (recipientName) | Name of the recipient group or contact (only for "wechatBroadcast"). |
等待时间 (waitTime) | Maximum wait time in seconds for QR code login when not using an already logged-in account (only for "wechatBroadcast" and when not using logged-in account). |
Output
The node outputs an array of JSON objects, one per input item, each containing:
success
: Boolean indicating if the operation succeeded.operation
: The operation performed (serialize
,unserialize
, orwechatBroadcast
).- For serialize:
result
: The PHP serialized string.originalData
: The original JSON object parsed from input.
- For unserialize:
result
: The unserialized data or extracted nested field ifextractPath
was provided.fullData
: The full unserialized object.
- For wechatBroadcast:
- On success: details about the message sent including type, recipient, and whether a logged-in account was used.
- On failure: an error message describing what went wrong.
If binary data were involved (e.g., images), it uses a file-box abstraction internally but outputs only JSON status and message info.
Dependencies
- Uses the
php-serialize
library for PHP serialization/unserialization. - Uses the
wechaty
andfile-box
libraries to interact with WeChat for broadcasting messages. - Requires a WeChat environment where either:
- A WeChat account is already logged in globally in the workflow environment, or
- The user can scan a QR code to log in dynamically during execution.
No explicit external API keys are required, but WeChat login credentials or session must be managed externally or via prior nodes.
Troubleshooting
Common Issues:
- Failure to unserialize invalid or malformed PHP serialized strings.
- JSON parse errors when serializing invalid JSON input.
- WeChat login timeout if QR code is not scanned within the specified wait time.
- Unable to find the specified WeChat group or contact by name.
- Using "useLoggedInAccount" without a logged-in WeChat session available.
Error Messages and Resolutions:
"没有找到已登录的微信账号,请先使用微信登录节点登录"
: No logged-in WeChat account found; run a WeChat login node first."扫码登录超时,请扫描二维码登录"
: Login timed out waiting for QR code scan; increase wait time or scan promptly."找不到群聊: <name>"
or"找不到好友: <name>"
: The specified recipient does not exist or the name is incorrect; verify recipient names.- JSON parsing errors: Ensure the input JSON data is valid and properly formatted.
- PHP unserialize errors: Confirm the input string is a valid PHP serialized string.
Links and References
This summary covers the static analysis of the node's execute method and its properties for the "Default" resource and "PHP 序列化" operation context.