WeChat Official Account icon

WeChat Official Account

微信公众号API操作

Actions4

Material → Add Material

AI-generated

Overview

This node integrates with the WeChat Official Account API to add permanent media materials of various types. Specifically, the "Add Material" operation under the "Material" resource allows users to upload different kinds of media such as images, voice recordings, videos, or thumbnails either by providing Base64 encoded data or a direct media URL.

Common scenarios for this node include:

  • Uploading multimedia content to a WeChat Official Account for later use in posts or messages.
  • Managing permanent media assets programmatically within an automation workflow.
  • Supporting different media input methods (Base64 or URL) to accommodate diverse data sources.

Practical example:

  • A marketing team automates uploading promotional videos and images to their WeChat Official Account by feeding media files directly from their content management system into this node using Base64 encoding or URLs.

Properties

Name Meaning
Material Type The type of media material to add. Options: Image, Voice, Video, Thumb
Input Type The method of providing the media file. Options: Base64 Encoded Data, Media URL
Media File The path or Base64 encoded string of the media file to upload. Required if Input Type is Base64
Media URL The URL link to the media file. Supported formats for images are jpg/png with size limit <1MB. Required if Input Type is URL

Output

The node outputs a JSON object containing the response from the WeChat Official Account API after attempting to add the material. This typically includes metadata about the uploaded media such as media IDs or error messages if the upload failed.

No binary data output is produced by this node; all results are returned as JSON.

Example output structure (simplified):

{
  "media_id": "MEDIA_ID_STRING",
  "url": "URL_TO_UPLOADED_MEDIA"
}

If an error occurs and "Continue On Fail" is enabled, the output will contain an error message like:

{
  "error": "Error message describing what went wrong"
}

Dependencies

  • Requires an active WeChat Official Account API credential with appropriate permissions.
  • The node uses internal helper functions to make authenticated HTTP requests to WeChat's API endpoints.
  • No additional external dependencies beyond the configured API credentials.

Troubleshooting

  • Common issues:

    • Providing an unsupported media format or exceeding size limits (especially for image URLs).
    • Incorrect Base64 encoding or invalid media file paths.
    • Network or authentication errors due to invalid or expired API credentials.
  • Error messages:

    • Errors returned from the WeChat API will be passed through in the output JSON under an error field if "Continue On Fail" is enabled.
    • Common error messages might indicate invalid media type, missing required parameters, or authentication failures.
  • Resolutions:

    • Verify media file formats and size constraints before uploading.
    • Ensure Base64 strings are correctly encoded without extra characters.
    • Confirm that the API credentials are valid and have not expired.
    • Use the "Continue On Fail" option during testing to capture detailed error information without stopping the workflow.

Links and References

Discussion