Go、PHP、VB、JavaScript、Node.js 等更多对接方式。
// === Go ===
package main
import (
"crypto/md5"
"encoding/hex"
"fmt"
"io"
"net/http"
"strconv"
"time"
)
func sign(act, card, mac, app string, ts int64, key string) string {
raw := fmt.Sprintf("%s|%s|%s|%s|%d|%s", act, card, mac, app, ts, key)
h := md5.Sum([]byte(raw))
return hex.EncodeToString(h[:])
}
func call(act, card, mac string) string {
ts := time.Now().Unix()
s := sign(act, card, mac, "a", ts, "APP_KEY")
url := fmt.Sprintf("https://你的域名/kami/user/check.php?act=%s&app=a&card=%s&mac=%s&sign=%s&ts=%d",
act, card, mac, s, ts)
resp, _ := http.Get(url)
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
return string(b)
}
func main() { fmt.Println(call("login", "CARD", "MAC")) }
// === PHP ===
// === Node.js / JavaScript (Browser/Electron) ===
const crypto = require("crypto");
function sign(act, card, mac, app, ts, key) {
return crypto.createHash("md5")
.update(`${act}|${card}|${mac}|${app}|${ts}|${key}`)
.digest("hex");
}
async function call(act, card, mac) {
const ts = Math.floor(Date.now() / 1000);
const s = sign(act, card, mac, "a", ts, "APP_KEY");
const url = `https://你的域名/kami/user/check.php?act=${act}&app=a`
+ `&card=${card}&mac=${mac}&sign=${s}&ts=${ts}`;
const r = await fetch(url);
return await r.text();
}
// === VB.NET / VBA ===
' Module 中加入:
Function Sign(act As String, card As String, mac As String, app As String, ts As String, key As String) As String
Dim raw As String
raw = act & "|" & card & "|" & mac & "|" & app & "|" & ts & "|" & key
Sign = LCase$(MD5_String(raw)) ' 需自行实现或引用 MD5 库
End Function