Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use JS to implement Base64 coding and MD5 encryption to complete express bird API interface call

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to use JS to achieve Base64 coding and MD5 encryption to complete express bird API interface call", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "how to use JS to achieve Base64 coding and MD5 encryption to complete express bird API interface call"!

JS calls the API interface function GetAPI () {var key= "Express Bird API Key"; var id = "Express Bird Registration ID"; var requestData= "{'OrderCode':'','ShipperCode':'ZTO','LogisticCode':'78120038107849'}" / / MD5 encryption var md5str = md5 (requestData + key). ToLowerCase (); / / base64 var dataSign = Base64.encode (md5str); / / concatenate string (express bird request message format) url encoding var reqData = "RequestData=" + escape (requestData) + "& EBusinessID=" + id + "& RequestType=1002&DataSign=" + escape (dataSign) + "& DataType=2" / / reqData = "RequestData=%7b%27OrderCode%27%3a%27%27%2c%27ShipperCode%27%3a%27ZTO%27%2c%27LogisticCode%27%3a%2778120038107849%27%7d&EBusinessID=1264783&RequestType=1002&DataSign=NzMxNTAzZWYxYTJiOGIyMDhiNTVjMTc4MDQ0NjdlZDg%3d&DataType=2" / / trigger before calling SubmitPost ({method: 'post', url:' / api/dist', data: reqData, beforeSend: function (xhr) {/ /) Such as loading effect, success: function (data, status) {if (status) {document.getElementById ("msg") [xss_clean] = "" For (var I = 0, len = data.Traces.length; I < len; itemstation) {var acceptTime = data.Tracs [I] .AcceptTime; var acceptStation = data.Traces [I] .AcceptStation / / the display effect of the page is developed by itself. Here, only the function document.getElementById ("msg") [xss_clean] + = acceptTime + "" + acceptStation+ "" is implemented. }}, error: function (data, status, e) {if (data.status = = "401") {alert (data.status); return });}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report