微信公众号 icon

微信公众号

微信公众号 API

Overview

This node integrates with the WeChat Official Account API to manage custom menus. Specifically, the "创建菜单" (Create Menu) operation under the "自定义菜单" (Custom Menu) resource allows users to define and create a new menu structure for their WeChat official account. This is useful for businesses or content creators who want to customize the navigation experience within their WeChat public profile, enabling users to access different features or content directly from the menu.

Practical examples include:

  • Creating a multi-level menu with buttons linking to various sections of a website or mini-program.
  • Setting up quick access buttons for customer service, promotions, or frequently used features.
  • Dynamically updating the menu based on campaigns or user feedback.

Properties

Name Meaning
菜单内容 (menus) The JSON-formatted menu content representing the collection of buttons under the button property. Users provide only the array of buttons without wrapping it in a button attribute. This defines the structure and actions of the custom menu to be created.

Output

The node outputs JSON data representing the response from the WeChat API after attempting to create the custom menu. This typically includes success confirmation or error details related to the menu creation request.

No binary data output is involved in this operation.

Dependencies

  • Requires an API key credential for authenticating with the WeChat Official Account API.
  • The base URL defaults to https://api.weixin.qq.com/cgi-bin/ but can be overridden via credentials.
  • The node sends HTTP requests with JSON payloads and expects JSON responses.

Troubleshooting

  • Common issues:

    • Invalid JSON format in the "菜单内容" property can cause request failures.
    • Insufficient permissions or incorrect API credentials will result in authentication errors.
    • Exceeding WeChat API rate limits or invalid menu structure may trigger API errors.
  • Error messages:

    • Errors returned by the WeChat API usually contain an error code and message. For example, "40018" indicates an invalid button type.
    • Authentication errors suggest checking the provided API key or token.
    • JSON parsing errors indicate malformed input in the menu content.

To resolve these:

  • Validate the JSON structure before sending.
  • Ensure the API credentials are correct and have necessary permissions.
  • Refer to WeChat API documentation for valid menu formats and limitations.

Links and References

Discussion