Updated on 2025-11-13 GMT+08:00

WeChat Channel Interface Authentication

Function

This interface is used for MO message authentication on WeChat.

Interface Authentication

// (1) Sort the values of token, timestamp, and nonce in alphabetical order.
ArrayList<String> validations = new ArrayList<>();
validations.add(verifyCode);
validations.add(timestamp);
validations.add(nonce);
Collections.sort(validations);
// (2) Concatenate the three parameter strings into a character string for digest signing.
try {
    return SignatureEncryptUtil.getDigestByAlgorithm(joinStr(validations), algorithm);
} catch (NoSuchAlgorithmException e) {
    log.error("Failed to generate signature");
    throw new AiccCommonException(e);
}

The SHA1 encryption algorithm has security risks. Exercise caution when using this algorithm.

Interface Prototype

Table 1 Interface prototype description

Method

GET

URL

https://{IP address}:{Port number}/social/on/wechat/{channelId}

{IP address}:{Port number} indicates the IP address and port number of the NSLB exposed externally.

{channelId} indicates the channel ID.

Request Parameters

Table 2 Request parameter

Parameter

Mandatory or Not

Type

Default Value

Description

Content-Type

Yes

String

None

The value is fixed at application/json; charset=UTF-8.

Table 3 Request body parameters

Parameter

Mandatory or Not

Type

Default Value

Description

nonce

Yes

String

None

Random number.

signature

Yes

String

None

Signature.

echostr

Yes

String

None

Random character string.

Response Parameters

If this interface is invoked successfully, no response is returned.

If this interface fails to be invoked, the corresponding status code and error description are returned.

Example

  • Request
    POST /social/on/wechat/202105112580330807
    Authorization: auth-v2/ak/2018-07-02T02:45:50Z/content-length;content-type;host/
    *******************
    Accept: */*
    Content-Type: application/json;charset=UTF-8
    Content-Length: 193
  • Response
    Status Code: 500
    response: "WeChatMessaging send failed"