有数验证 webhook url 有效性

  • 有数在通过该验证后,才会把对应的 webhook 添加到有数中。Get 请求,url 为用户配置的 http(s)://host。
  • 请求地址及参数:
    • 请求地址:http(s)://host?timestamp=TIMESTAMP&nonce=NONCE&signature=SIGNATURE
    • timestamp(long):调用 webhook 时的时间戳
    • nonce(long):随机数
    • signature(String):先对 timestamp,nonce,secret 进行字典序排序后拼接成一个字符串,然后求 sha1 的结果。即 sha1(sort(timestamp,nonce,secret)) 。Webhook 端可根据该字段的值判断请求是否来自于有数(也可以不判断)。示例:
      long timestamp = 1583890769246;
      long nonce = 5111011325335330;
      String secret = "gzBDV9AMbGfHcf28";
      String sortedString = Arrays.sort([timestamp.toString, nonce.toString, secret]) = "15838907692465111011325335330gzBDV9AMbGfHcf28";
      String signature = sha1(sortedString) = "6460c444cf9df23a73717d16f7101199e79b8ec2";
  • 返回:
    • {"code":0,"msg":"ok"}
    • content-type:”application/json”
    • 有数使用 code == 0 来判断 webhook 是否有效。