National Express API interface document – access technology FAQ – interface source code reuse

Time:2021-11-25

Express 100api interface FAQ. This content is the technical docking FAQ to solve the problems encountered in the process of docking express 100api interface. If this article does not cover your question,Please visit the official website and contact technicians and operators to help you deal with it 1-to-1

Question 1. How to handle the sign in the express 100api interface?

The encryption method of express 100 is unified as MD5 and then converted to uppercase, which can be used for referenceautograph

org.apache.commons.codec.digest.DigestUtils.md5Hex(msg).toUpperCase();

Question 2. How to handle the callback interface after using the express 100 subscription interface?

You can refer to pushSubscription callback

public SubscribeResp callBackUrl(HttpServletRequest request){
        String param = request.getParameter("param");
        String sign = request.getParameter("sign");
        //It is recommended to record the contents of this callback to facilitate the troubleshooting of both parties after a problem occurs
        Log. Debug ("express 100 subscription push callback result | {} | {}", param, sign);
        //No salt passed during subscription can be ignored
        String salt = "";
        String ourSign = SignUtils.sign(param + salt);
        SubscribeResp subscribeResp = new SubscribeResp();
        subscribeResp.setResult(Boolean.TRUE);
        subscribeResp.setReturnCode("200");
        Subscriberesp.setmessage ("success");
        //If the encryption is equal, it belongs to express 100 push; Otherwise, the current request can be ignored
        if (ourSign.equals(sign)){
            //Todo business processing
            return subscribeResp;
        }
        return null;
    }

Q3. How to handle the returned Base64 pictures when using the electronic single picture interface?

The returned string is a JSON array. When there are multiple sub orders, there will be multiple.

Add the prefix “data: image / PNG; Base64,” “, and replace” \ n “with” “; You can refer to the base64 string returned by processing

public List<String> getBase64Img(String imgBase64){
        List<String> stringList= new Gson().fromJson(imgBase64,
                                 new TypeToken<List<String>>() {}.getType());
        List<String> base64Img = new ArrayList<String>();
        if (stringList != null && stringList.size()>0){
            for (String s : stringList) {
                s = "data:image/png;base64,"+s.replace("\\\\n","");
                base64Img.add(s);
            }
        }
        return base64Img;
    }

Question 4. How should other interfaces of the cloud platform be connected?

Step 1: add the corresponding request parameter class according to the corresponding interface and inherit cloudbasereq, which is similar to canceling the sending request parameter class of the express sending interface

public class COrderCancelReq extends CloudBaseReq{
    /**
     *Task ID
     */
    private String taskId;
    /**
     *Order ID
     */
    private String orderId;
    /**
     *Reason for cancellation, e.g. no mail for the time being
     */
    private String cancelMsg;
}

Step 2: when calling, you only need to replace it with the entity newly created in step 1

public void testCOrderCancel() throws Exception {
    COrderCancelReq cOrderCancelReq = new COrderCancelReq();
    cOrderCancelReq.setTaskId("B19BB4C6F33BE9E735A63D4142557751");
    cOrderCancelReq.setOrderId("11115207");
    Ctordercancelreq.setcancelmsg ("test sheet");
    cOrderCancelReq.setSecret_key(secret_key);
    cOrderCancelReq.setSecret_code(CloudApiCodeConstant.ORDER_CANCEL);
    cOrderCancelReq.setSecret_sign(SignUtils.cloudSign(secret_key,secret_secret));

    IBaseClient cloudBase = new CloudBase();
    System.out.println(cloudBase.execute(cOrderCancelReq));
}

Tips: key, secret, code and other account information acquisition, cloud platform – > buyer Center – my interface

[external chain picture transfer failed. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-ayx4yibl-1628578971336)(https://ask.qcloudimg.com/htt…]

Online technical support:https://api.kuaidi100.com/