点创节点 icon

点创节点

点创自定义节点,用于PHP序列化和反序列化操作

Overview

This node provides three main operations related to PHP serialization and WeChat messaging:

  • PHP Unserialize: Converts a PHP serialized string into a JSON object. This is useful when you receive data serialized by PHP and want to work with it in JSON format within n8n.
  • PHP Serialize: Converts a JSON object into a PHP serialized string. This helps when you need to send or store data in PHP serialized format.
  • WeChat Broadcast: Sends messages (text or image) to a specified WeChat contact or group chat, optionally using an already logged-in WeChat account or by logging in dynamically via QR code scanning.

Typical use cases include:

  • Integrating PHP-based systems with n8n workflows by converting serialized data back and forth.
  • Automating message broadcasts to WeChat groups or contacts from workflow triggers.
  • Extracting specific fields from complex PHP serialized data for further processing.

Properties

Name Meaning
Operation Choose the operation to perform: PHP 反序列化 (unserialize), PHP 序列化 (serialize), or 微信群发 (wechatBroadcast).
PHP 序列化字符串 The PHP serialized string to be unserialized (only for unserialize operation).
提取字段路径(可选) Optional dot-separated path to extract a specific field from the unserialized result, e.g., pay_download.0.link.
JSON 数据 JSON data to serialize into a PHP serialized string (only for serialize operation).
使用已登录的微信账号 Boolean flag to use an already logged-in WeChat account for broadcasting (only for wechatBroadcast).
消息类型 Type of message to send: 文本消息 (text) or 图片消息 (image) (only for wechatBroadcast).
消息内容 Text content of the message to send (only if message type is text and operation is wechatBroadcast).
图片URL URL of the image to send (only if message type is image and operation is wechatBroadcast).
接收者类型 Recipient type: 群聊 (room) or 好友 (contact) (only for wechatBroadcast).
接收者名称 Name of the recipient group or contact (only for wechatBroadcast).
等待时间(秒) Maximum wait time in seconds for QR code login when not using an already logged-in account (only for wechatBroadcast).

Output

The node outputs an array of JSON objects corresponding to each input item processed. The structure depends on the operation:

  • Unserialize:

    {
      "success": true,
      "operation": "unserialize",
      "result": <extracted field or full unserialized data>,
      "fullData": <full unserialized JSON object>
    }
    

    If extraction path is provided, result contains the extracted value; otherwise, it contains the entire unserialized object.

  • Serialize:

    {
      "success": true,
      "operation": "serialize",
      "result": "<PHP serialized string>",
      "originalData": <original JSON object>
    }
    
  • WeChat Broadcast:

    {
      "success": true,
      "operation": "wechatBroadcast",
      "messageType": "text" | "image",
      "recipientType": "room" | "contact",
      "recipientName": "<name>",
      "message": "<text content or image URL>",
      "usedLoggedInAccount": true | false
    }
    

    On failure, the output includes "success": false and an "error" message describing the issue.

If binary data were involved (e.g., images), the node uses URLs and FileBox abstraction internally but outputs only JSON metadata.

Dependencies

  • Uses the php-serialize npm package to handle PHP serialization and unserialization.
  • Uses the wechaty and file-box packages to interact with WeChat for message broadcasting.
  • For WeChat broadcast with dynamic login, requires scanning a QR code shown in logs to authenticate.
  • No explicit credential configuration is required for PHP serialization operations.
  • For WeChat broadcast, either an existing logged-in WeChat session must be available globally or the user must scan a QR code to log in during execution.

Troubleshooting

  • Common Issues:

    • Invalid PHP serialized strings will cause unserialize errors.
    • Malformed JSON input will cause serialization errors.
    • Failure to find the specified WeChat group or contact by name results in errors.
    • Using the "use logged-in account" option without an active logged-in session causes failure.
    • QR code login timeout if the user does not scan the code within the configured wait time.
  • Error Messages:

    • "没有找到已登录的微信账号,请先使用微信登录节点登录": Means no logged-in WeChat account was found; resolve by logging in first.
    • "找不到群聊: <name>" or "找不到好友: <name>": Indicates the specified recipient was not found; verify the recipient name.
    • "登录超时,请扫描二维码登录": Login timed out waiting for QR code scan; increase wait time or scan promptly.
    • PHP unserialize or JSON parse errors provide details about invalid input formats.

Links and References

These resources provide additional context on PHP serialization and WeChat bot integration used by this node.

Discussion