' ============================================================================
' Soo 验证系统 · 开放 API 按键精灵对接示例
' ============================================================================
' 适用:按键精灵 9 / 按键精灵 2014+ 脚本
' 说明:
'  - 按键精灵用 WebApi 免签 GET 查询(无需 HMAC 签名),开箱即用:
'      查卡密/账号到期、公告、版本、变量
'  - 登录/心跳等带签名接口,建议由你的服务端或配套小程序代为调用
'    (按键精灵脚本内做 HMAC-SHA256 需依赖第三方 DLL,这里不做展开)
' ============================================================================

' ---------- 配置(改成你的) ----------
Dim AppKey = "你的app_key"
Dim Server = "https://sooyz.com"

' ========== 1. 免签查卡密状态(到期时间/状态/绑机) ==========
' WebApi type=8:card=卡密 或 username=账号
Function QueryCard(card)
    Dim url = Server & "/api/client/webapi?appkey=" & AppKey & "&type=8&card=" & card
    ' 按键精灵取网页源码:Plugin.Web.Url.Get(网址, 编码, 超时秒)
    Dim html = Plugin.Web.Url.Get(url, "utf-8", 10)
    TracePrint "查卡结果:" & html
    ' 返回示例:{"code":0,"type":8,"data":{"card_no":"xxx","status":"used","points":0,
    '           "expire_at":"2026-11-14 16:00:00","bound_machine":"..."}}
    ' 到期判断:解析 expire_at 字段,与当前时间比较即可
    QueryCard = html
End Function

' ========== 2. 查公告(type=1) ==========
Function GetNotice()
    Dim url = Server & "/api/client/webapi?appkey=" & AppKey & "&type=1"
    Dim html = Plugin.Web.Url.Get(url, "utf-8", 10)
    TracePrint "公告:" & html
    GetNotice = html
End Function

' ========== 3. 查最新版本(type=3) ==========
Function GetVersion()
    Dim url = Server & "/api/client/webapi?appkey=" & AppKey & "&type=3"
    Dim html = Plugin.Web.Url.Get(url, "utf-8", 10)
    TracePrint "版本:" & html
    GetVersion = html
End Function

' ========== 4. 查变量配置(type=7) ==========
Function GetVars()
    Dim url = Server & "/api/client/webapi?appkey=" & AppKey & "&type=7"
    Dim html = Plugin.Web.Url.Get(url, "utf-8", 10)
    TracePrint "变量:" & html
    GetVars = html
End Function

' ---------- 主流程 ----------
Call GetNotice()          ' 先显示公告
Call QueryCard("测试卡密") ' 查你的卡密到期
Call GetVersion()         ' 查软件最新版本

' ============================================================================
' 说明:
' 1. 不同按键精灵版本网页命令名略有差异:Plugin.Web.Url.Get / Plugin.Web.Html.Get
'    / Url.Get 等,以你版本「插件命令-Web」为准;若均不可用,可改用
'    RunApp("cmd /c curl ...") 方案(需要系统有 curl,Win10+ 自带)。
' 2. WebApi type 一览:1公告 2核心数据 3最新版本 4VMP授权 5购卡链接
'    6下载地址 7变量 8卡/账号状态 9版本号名称 10注册配置。
' 3. 需要登录鉴权/心跳的完整接口见上级目录《接口文档.md》。
' ============================================================================
