HomeDocs
Skip to main content

Dynamic Material Update

In essence, submit the form containing the content to be updated, along with the required parameters, to the specified interface on the Mini Program Open Platform. We will provide the corresponding update content when the splash screen requests the Open Platform.

I. Environment Selection

EnvironmentAccess Prefix
Productionhttps://api.dlight-app.com/miniapp/launchplatformdeveloper/openapi
Indian Environmenthttps://api-ind.dlight-app.com/miniapp/launchplatformdeveloper/openapiTo push services to the Indian server, this domain needs to be called

II. Integration Approach

1. Pre-Integration Preparation

After a third party applies for integration with the Mini Program card, the Mini Program registers a form for updating the card. The third party obtains the form's ID (bizId), key, and the keys that can be updated. The third party can choose to synchronize or asynchronously obtain the return information.

  • Synchronous: Directly call the write interface and wait for the return.
  • Asynchronous: The third party provides a callback interface (see Chapter 3.6 for details).

2. OpenAPI Interfaces

2.1 Write Interface

Request URL: /cardform/cmd/sendCardForm Request Method: POST Request Header Parameters:

Parameter NameTypeRequiredDescription
Accept-TimezoneStringYesTimezone

OpenAPI Fields:

ParameterData TypeDescriptionRequiredSourceExample
dataCardFormInfoRequestDTOMaterial update paramstrueDeveloperSee CardFormInfoRequestDTO parameter
bizIdStringCard form IDtrueConsult the Mini Program team1000675095676309504
miniappIdStringMini Program IDtrueConsult the Mini Program team3000317415459377152
operatorIdStringOperator IDfalseConsult the Mini Program teamqewrqewrq-qweqwrqw
signStringSignature fieldtrueDeveloperFA8762C9BB9BE1B162D0386F1AB3
timeStampStringTimestampfalseDeveloper1690180572312
requestIdStringRequest IDtrueDeveloperqqrea

CardFormInfoRequestDTO Parameters:

ParameterData TypeDescription
textString(json)Form information (Note: If it is a deeplink parameter, it needs to be strongly validated according to the clickUrl rules, otherwise it will not pass)
cardFormReceiverInfoCardFormReceiverInfoDTOReceiver information for the form

CardFormReceiverInfoDTO Parameters:

ParameterData TypeDescription
uniqueIdsList<String>Array of uniqueIds (up to 50 at a time), and when this field is not empty, label information is not processed
keywordStringKeyword: Cannot be empty if the card is a full search scene
labelsList<LabelDTO>Array of recipient labels

LabelDTO Parameters:

ParameterData TypeDescription
labelNameStringLabel name
labelValueStringLabel value

2.2 Query Interface

Request URL: /cardform/cmd/getCardForm Request Method: POST Request Header Parameters:

Parameter NameTypeRequiredDescription
Accept-TimezoneStringYesTimezone

2.3 OpenAPI Signature

3.1 Message Signature Explanation

Use RSA to verify the authenticity and integrity of the data during data transmission. The data needs to be digitally signed. After receiving the signed data, verify the signature. Sign the entire message, then assign it to the sign field. Sign only the data field during signing.

3.2 Signature Method

The signature algorithm used is SHA256withRSA. Verify the signature first when returning the message, then deserialize it into an object.

3.3 Assembling the Signature Message

Sort the values of the data field in the request message in ascending order of ASCII code, connecting them with "&". If the initial letters of the names are the same, compare the second letters, and so on, to concatenate them into a string in the format of key=value&key=value. Then sign it.

3.4 Signature Data Example

Java Code Example:


@Slf4j
public class EncryptSha256Util {
private EncryptSha256Util() {
throw new IllegalStateException("EncryptSha256Util class");
}

/**
* sha256加密
*
* @param str 要加密的字符串
* @return 加密后的字符串
*/
public static String getSha256Str(String str) {
MessageDigest messageDigest;
String encodeStr = "";
try {
messageDigest = MessageDigest.getInstance("SHA-256");
messageDigest.update(str.getBytes(StandardCharsets.UTF_8));
encodeStr = byte2Hex(messageDigest.digest());
} catch (NoSuchAlgorithmException e) {
log.error("进行sha256加密失败!massage:{}", e.getMessage());
}
return encodeStr;
}

/**
* sha256加密 将byte转为16进制
*
* @param bytes 字节码
* @return 加密后的字符串
*/
private static String byte2Hex(byte[] bytes) {
StringBuilder stringBuilder = new StringBuilder();
String tempStr;
for (byte aByte : bytes) {
tempStr = Integer.toHexString(aByte & 0xFF);
if (tempStr.length() == 1) {
//得到第一位的进行补0操作
stringBuilder.append("0");
}
stringBuilder.append(tempStr);
}
return stringBuilder.toString();
}

public static void main(String[] args) {
getCardFormParm();
SetCardFormParm();
}

//查询接口参数
private static void getCardFormParm() {
CardRequestDTO<GetCardFormReceiverInfoDTO>res = new CardRequestDTO<>();
String timeStamp = System.currentTimeMillis()+"";
String secretAccessKey = "Your AccessKeySecret";
String miniappId = "1000083312531542016";
String bizId = "101691407379048";
String requestId = "fdsagfsdgfsdagsdg";
String operatorId = "11";
GetCardFormReceiverInfoDTO dto = new GetCardFormReceiverInfoDTO();
dto.setUniqueId("04820f410572fee703273addc166a41aeead24de447d8abd8e08eacd44e3d901");
dto.setKeyword("iphone");
List<LabelDTO> labels = new ArrayList<>();
LabelDTO dto1 = new LabelDTO();
dto1.setLabelName("country");
dto1.setLabelValue("406");
LabelDTO dto2 = new LabelDTO();
dto2.setLabelName("brand");
dto2.setLabelValue("cy");
LabelDTO dto3 = new LabelDTO();
dto3.setLabelName("model");
dto3.setLabelValue("acth");

LabelDTO dto4 = new LabelDTO();
dto4.setLabelName("model111");
dto4.setLabelValue("mode");
labels.add(dto1);
labels.add(dto2);
labels.add(dto3);
labels.add(dto4);
dto.setLabels(labels);
String requestStr = "requestId=" + requestId + "&bizId=" + bizId +"&miniappId=" + miniappId + "&operatorId=" + operatorId + "&data=" + JSONObject.toJSONString(dto) + "&timeStamp=" + timeStamp;

String secretAccessKeySign = "&secretAccessKey=" + secretAccessKey;
requestStr = requestStr + secretAccessKeySign;
String sign = EncryptSha256Util.getSha256Str(requestStr).toUpperCase();
res.setData(dto);
res.setBizId(bizId);
res.setRequestId(requestId);
res.setMiniappId(miniappId);
res.setOperatorId(operatorId);
res.setTimeStamp(timeStamp);
res.setSign(sign);
System.out.println(JSONObject.toJSONString(res));
}

//更新接口参数
private static void SetCardFormParm() {
CardRequestDTO<CardFormInfoRequestDTO>res = new CardRequestDTO<>();

String timeStamp = System.currentTimeMillis()+"";
String secretAccessKey = "Your AccessKeySecret";
String miniappId = "1000083312531542016";
String bizId = "101691407379048";
String requestId = "fdsagfsdgfsdagsdg";
String operatorId = "11";
CardFormInfoRequestDTO dto = new CardFormInfoRequestDTO();
JSONObject textJson = new JSONObject();
textJson.put("imageUrl", "title_uniqueid_555_gaid");
textJson.put("ClickUrl", "https://app-oss.byte-app.com/demoapp/Sryb8HnKqK.jpg");
dto.setText(textJson.toJSONString());
CardFormReceiverInfoDTO info = new CardFormReceiverInfoDTO();
List<String> uniqueIds = new ArrayList<>();
uniqueIds.add("4dc737855eb61401d6e426f61799a0156831356b0fc51848557034b20a7c3546");
uniqueIds.add("85e267220b86c309a85b4e86142366af813304e581014258dd9a0585cd898069");
uniqueIds.add("c81962159ee8417b8e113abb4ce4670f98c3941c97d86c13f1e521def2c62af0");
uniqueIds.add("04820f410572fee703273addc166a41aeead24de447d8abd8e08eacd44e3d901");
info.setUniqueIds(uniqueIds);
info.setKeyword("iphone");
List<LabelDTO> labels = new ArrayList<>();
LabelDTO dto1 = new LabelDTO();
dto1.setLabelName("country");
dto1.setLabelValue("406");
LabelDTO dto2 = new LabelDTO();
dto2.setLabelName("brand");
dto2.setLabelValue("cy");
LabelDTO dto3 = new LabelDTO();
dto3.setLabelName("model");
dto3.setLabelValue("acth");

labels.add(dto1);
labels.add(dto2);
labels.add(dto3);
info.setLabels(labels);
dto.setCardFormReceiverInfo(info);
String requestStr = "requestId=" + requestId + "&bizId=" + bizId +"&miniappId=" + miniappId + "&operatorId=" + operatorId + "&data=" + JSONObject.toJSONString(dto) + "&timeStamp=" + timeStamp;

String secretAccessKeySign = "&secretAccessKey=" + secretAccessKey;
requestStr = requestStr + secretAccessKeySign;
String sign = EncryptSha256Util.getSha256Str(requestStr).toUpperCase();

res.setData(dto);
res.setBizId(bizId);
res.setRequestId(requestId);
res.setMiniappId(miniappId);
res.setOperatorId(operatorId);
res.setTimeStamp(timeStamp);
res.setSign(sign);
System.out.println(JSONObject.toJSONString(res));

}

}


4. Data specification

4.1 Request Message Specification

The response message is divided into two layers:

  • Outer layer: Common parameters
  • Inner layer [data]: Business-specific parameters

The content body [data] is returned when the code is equal to 0.

{
"data": {
"cardFormReceiverInfo": {
"labels": [
{ "labelName": "country", "labelValue": "ch" },
{ "labelName": "brand", "labelValue": "brand1" },
{ "labelName": "model", "labelValue": "model2" },
{ "labelName": "model111", "labelValue": "model1" },
{ "labelName": "serviceProvider", "labelValue": "serviceProvider1" }
],
"uniqueIds": [
"003c92f3245bddbe736eefd66a7b55c3b9cb04f446c4d3a13b1ec0dc4ae99a01"
]
},
"text": "{\"titleName\":\"logo222\",\"backLogo\":\"name222\",\"checkurl\":\"title222\",\"titleValue\":\"http://hhh.html\"}"
},
"formId": "101690449368932",
"miniappId": "1000083312531542016",
"operatorId": "11",
"sign": "F87E21E1ECDB776001134AA94C89A6F13D70DFF6F687B5749AE845B6A476E229",
"timeStamp": "1690458554576"
}

Response Result

Response ParameterData TypeDescription
codeIntegerError status code
messageStringReturn message
dataCardFormInfoVoSee parameters in CardFormInfoVo

CardFormInfoVo Parameters

Response ParameterData TypeDescription
successUniqueIdlist<String>When updating multiple unique IDs in a single request, returns successful unique IDs
errorUniqueIdlist<String>When updating multiple unique IDs in a single request, returns failed unique IDs

Example:

{
"code": 0,
"message": null,
"data": {
"successUniqueId": ["gsdgsdfgsdfss"],
"errorUniqueId": ["gsdgsdfgsdf"]
},
"sign": "CDD73496515A7F9B66E620CB39470F560A93730E5B4F4C24474E342C4F1B7945"
}

Status Codes

Status CodeDescription
10004Data JSON parsing exception
10005Signature exception
10007Permission exception
20001Form ID does not exist
20002Form ID does not match Mini Program ID
20006Failed to update form
20007DATA form data cannot be empty or missing
20008Exceeded limit for sending user IDs
20009Value for the given key cannot be empty
30001User unique ID does not exist
00002Request throttled
4.2 Callback Interface
  • Request URL: Provided by the developer

  • Request Method: POST

  • Input Parameters:

    ParameterData TypeRemarks
    requestIdstringRequest ID at the time of writing
    returInforeturInfoSee 3.5 Response Result

Is the DeepLink link passed in the material correct, the format is as follows:

  • Shell Mini Program form: launcherdlt://miniapp?appId={miniappid}&h5Path =xxx&query=yyy

    1. Skip to the front page without additional parameters: h5Path=&query=
    2. Jump to the specific path without additional parameters: h5Path=xxx&query=; xxx represents the page path
    3. Jump to the specific path, you need to carry additional parameters: h5Path=xxx &query=yyy; xxx represents the page path, yyy is the carried parameter, xxx, yyy needs to encode
    4. Example: https://www.xxx.com/example?param=1
      1. /example encoding% 2Fexample
      2. Do encoding param%3D1 for param=1
      3. Update material interface pass value h5Path =%2Fexample&query=param%3D1
  • Regular Mini Program form: launcherdlt://miniapp?appId={miniappid}&page=xxx&query=yyy

    1. Jump to the front page without additional parameters: page=&query=
    2. Jump to the specific path without additional parameters: page=xxx&query=; xxx represents the page path
    3. Jump to the specific path, you need to carry additional parameters: page=xxx&query=yyy; xxx represents the page path, yyy is the parameter carried, yyy needs to encode
    4. Example: launcherdlt://miniapp?appId={miniappid}&page=pages/index/index, parameter is param = 1
      1. Do encoding param%3D1 for param = 1
      2. Update the material interface to pass value page=pages/index/index&query=param%3D1
  • Multi- Mini Program Type Card: This card is bound to a default Mini Program defaultMiniappId, but the card can also jump to other Mini Programs

    1. If you jump to the default Mini Program , generate link parameters according to the a, b rules
    2. If you jump to the non-default Mini Program jumpMiniappId, after generating the link based on the a, b rules, splice the parameter appId = {jumpMiniappId} & in front of the link, the example is as follows
      1. Jump to Mini Program : 300000 ( h5 MiniProgram)
      2. Jump link: https://www.xxx.com/example?param=1
      3. Because it is h5 Mini Program , according to a rule, generate: h5Path =%2Fexample&query = param%3D1
      4. Final link parameter appId=300000&h5Path=%2Fexample&query=param%3D1
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.