# 接口客户端: 点我下载

# 接口客户端使用示例(Node.js):


/**
 * 猫酷开放平台接入示例
 */ 
var fetch = require("node-fetch");
var moment = require("moment");
var crypto = require("crypto");

/**
 * 开发者应用账号
 */
const AppID = "";
const PublicKey = "";
const PrivateKey = "";


/**
 * mallcoo post 请求
 * @param string url 请求url
 * @param obj postData 请求参数
 * @return obj
 */
function mallcooPost(url, postData) {
  let postdata_str = JSON.stringify(postData);
  let TimeStamp = moment().format("YYYYMMDDhhmmss");
  let encryptString = `{publicKey:${PublicKey},timeStamp:${TimeStamp},data:${postdata_str},privateKey:${PrivateKey}}`;
  let md5_str = crypto.createHash("md5").update(encryptString).digest("hex");
  let Sign = md5_str.slice(8, 24).toUpperCase();

  //Headers
  let headers = {
    "Content-Type": "application/json; charset=utf-8",
    "Content-Length": postdata_str.length,
    AppID,
    TimeStamp,
    PublicKey,
    Sign
  };

  //Post
  fetch(url, { method: "POST", body: postdata_str, headers })
    .then(res => {
      return res.json();
    })
    .then(json => console.log(json));
}

/**
 * 获取商户详情
 * @param string url 请求url
 * @param obj postData 请求参数
 * @return obj
 */
function getShopDetail() {
  let url = "https://openapi10-t.mallcoo.cn/Shop/V1/GetDetail/";
  let postData = {
    McShopID: 1000035,
    CrmShopID: "",
    DevShopID: ""
  };

  mallcooPost(url, postData);
}

getShopDetail();




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Last Updated: 2021/3/31 上午11:15:32