Skip to content

Python SDK

T3 网络验证 Python SDK,支持 Base64 自定义编码集和 RSA 两种加密算法。

适用场景

  • Python 桌面应用 / 脚本工具
  • 适用于 Python 3.6+

包管理器安装

bash
pip install t3sdk
python
from t3sdk import T3Verify, get_machine_code

手动下载

依赖说明

  • Base64 模式:无额外依赖
  • RSA 模式:需安装 pycryptodome
bash
pip install pycryptodome

初始化

方式一:Base64 自定义编码集

python
from t3sdk.t3sdk import T3Verify, get_machine_code

verify = T3Verify()
verify.init(
    login_code='你的单码登录调用码',
    notice_code='你的公告调用码',
    version_code='你的版本号调用码',
    heartbeat_code='你的心跳调用码',
    appkey='你的程序APPKEY',
    base64_charset='你的Base64自定义编码集',
    encode_type='base64',
)

方式二:RSA 算法 + HEX 编码 推荐

python
from t3sdk.t3sdk import T3Verify, get_machine_code

verify = T3Verify()
verify.init(
    login_code='你的单码登录调用码',
    notice_code='你的公告调用码',
    version_code='你的版本号调用码',
    heartbeat_code='你的心跳调用码',
    appkey='你的程序APPKEY',
    rsa_public_key='-----BEGIN PUBLIC KEY-----\n你的RSA公钥\n-----END PUBLIC KEY-----',
    encode_type='rsa',
    # 如需使用更多接口,可在此传递更多调用码参数:
    # query_code='查询卡密调用码',
    # register_code='用户注册调用码',
    # user_login_code='用户登录调用码',
    # ... 更多调用码
)

后台配置

使用 SDK 前,请先完成 后台快速配置。您也可以在后台「SDK 下载与注入」页面一键自动配置并下载已注入配置信息的 SDK,无需手动填写。

推荐调用顺序

API 方法参考

获取机器码

python
machine_code = get_machine_code()

返回当前设备的唯一标识字符串。


获取程序公告 get_notice()

python
result = verify.get_notice()
if result['success']:
    print(f"公告: {result['notice']}")
else:
    print(f"失败: {result['error']}")

返回值dict

字段类型说明
successbool是否成功
noticestr公告内容
errorstr错误信息(失败时)

获取最新版本号 get_latest_version()

python
result = verify.get_latest_version()
if result['success']:
    print(f"最新版本: {result['version']}")

返回值dict

字段类型说明
successbool是否成功
versionstr最新版本号
errorstr错误信息

检查更新 check_update(ver)

python
result = verify.check_update('1000')  # 传入当前版本号
if result['success']:
    if result.get('has_update'):
        print(f"最新版本: {result['ver']}")
        print(f"更新公告: {result.get('uplog', '')}")
        print(f"下载地址: {result.get('upurl', '')}")

参数

参数类型说明
verstr当前程序版本号

单码卡密登录 login(kami, imei)

python
result = verify.login(card, machine_code)
if result['success']:
    print(f"登录成功! 到期时间: {result['end_time']}")
    statecode = result['statecode']  # 保存,心跳验证需要

参数

参数类型说明
kamistr卡密值
imeistr机器码

返回值dict

字段类型说明
successbool是否成功
idint卡密 ID
end_timestr到期时间
statecodestr状态码(心跳验证用)
errorstr错误信息

单码心跳验证 heartbeat(kami, statecode)

python
result = verify.heartbeat(card, statecode)
if result['success']:
    print("心跳验证成功")

参数

参数类型说明
kamistr卡密值
statecodestr登录返回的状态码

查询卡密信息 query_kami(kami)

python
result = verify.query_kami(card)
if result['success']:
    print(f"到期时间: {result['end_time']}")
    print(f"剩余时间: {result['available']}秒")

用户注册 user_register(user, password, email)

python
result = verify.user_register('username', 'password', 'email@example.com')
if result['success']:
    print("注册成功")

用户登录 user_login(user, password, imei)

python
result = verify.user_login('username', 'password', machine_code)
if result['success']:
    print(f"到期时间: {result['end_time']}")
    user_statecode = result['statecode']

用户心跳验证 user_heartbeat(user, password, statecode)

python
result = verify.user_heartbeat('username', 'password', user_statecode)

用户充值 recharge(user, card)

python
result = verify.recharge('username', 'recharge_card')

用户绑定QQ bind_qq(user, password, openid, access_token)

python
result = verify.bind_qq('username', 'password', 'openid', 'access_token')

用户QQ登录 qq_login(openid, access_token)

python
result = verify.qq_login('openid', 'access_token')

解绑设备 unbind_kami / unbind_user

python
# 单码解绑
result = verify.unbind_kami(card, machine_code)
print(f"  {result['msg']}" if result['success'] else f"  失败: {result['error']}")
# 用户解绑
result = verify.unbind_user('username', 'password', machine_code)
print(f"  {result['msg']}" if result['success'] else f"  失败: {result['error']}")

IP 解绑 ip_unbind_kami / ip_unbind_user

python
# 单码 IP 解绑
result = verify.ip_unbind_kami(card)
print(f"  {result['msg']}" if result['success'] else f"  失败: {result['error']}")
# 用户 IP 解绑
result = verify.ip_unbind_user('username', 'password')
print(f"  {result['msg']}" if result['success'] else f"  失败: {result['error']}")

获取远程变量 get_variable_by_kami / get_variable_by_user

python
# 通过卡密获取
result = verify.get_variable_by_kami(card, '变量ID', '变量名称')
# 通过用户获取
result = verify.get_variable_by_user('username', 'password', '变量ID', '变量名称')
if result['success']:
    print(f"变量值: {result['value']}")

修改远程变量 modify_variable_by_kami / modify_variable_by_user

python
# 通过卡密修改
result = verify.modify_variable_by_kami(card, '变量ID', '新内容')
print(f"  {result['msg']}" if result['success'] else f"  失败: {result['error']}")
# 通过用户修改
result = verify.modify_variable_by_user('username', 'password', '变量ID', '新内容')
print(f"  {result['msg']}" if result['success'] else f"  失败: {result['error']}")

修改核心数据 modify_core_by_kami / modify_core_by_user

python
# 通过卡密修改
result = verify.modify_core_by_kami(card, '核心数据')
print(f"  {result['msg']}" if result['success'] else f"  失败: {result['error']}")
# 通过用户修改
result = verify.modify_core_by_user('username', 'password', '核心数据')
print(f"  {result['msg']}" if result['success'] else f"  失败: {result['error']}")

获取核心数据 get_core_by_kami / get_core_by_user

python
# 通过卡密获取
result = verify.get_core_by_kami(card)
if result['success']:
    print(f"核心数据: {result['core']}")

# 通过用户获取
result = verify.get_core_by_user('username', 'password')
if result['success']:
    print(f"核心数据: {result['core']}")

返回值dict

字段类型说明
successbool是否成功
corestr核心数据内容
errorstr错误信息

获取在线数量 get_online_kami_count / get_online_user_count

python
# 获取在线卡密数量
result = verify.get_online_kami_count()
if result['success']:
    print(f"在线卡密数: {result['count']}")

# 获取在线用户数量
result = verify.get_online_user_count()
if result['success']:
    print(f"在线用户数: {result['count']}")

返回值dict

字段类型说明
successbool是否成功
countint在线数量
errorstr错误信息

获取云文档 get_cloud_doc(token)

python
result = verify.get_cloud_doc('云文档Token')
if result['success']:
    print(f"内容: {result['content']}")

应用签名比对 app_sign(autograph)

python
result = verify.app_sign('应用签名')
if result['success']:
    print(f"  {result['msg']}")
    print(f"  后台签名: {result['autograph']}")
else:
    print(f"  失败: {result['error']}")

用户修改密码 change_password(user, oldpass, newpass)

python
result = verify.change_password('username', '旧密码', '新密码')

禁用 disable_kami / disable_user

python
# 禁用卡密
result = verify.disable_kami(card)
# 禁用用户
result = verify.disable_user('username', 'password')

用户注销 user_cancel(user, password)

python
result = verify.user_cancel('username', 'password')

完整示例

python
from t3sdk.t3sdk import T3Verify, get_machine_code

def main():
    verify = T3Verify()

    # 初始化(RSA 模式)
    verify.init(
        login_code='F2FA89AD46C050B2',
        notice_code='3512425FE75AE73A',
        version_code='F119CF1323743DBC',
        heartbeat_code='B1D2263C3702177F',
        appkey='5d116108006a454d538839ccff2d32f9',
        rsa_public_key='-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----',
        encode_type='rsa',
    )

    card = '你的卡密'
    machine_code = get_machine_code()

    # 1. 获取公告
    result = verify.get_notice()
    if result['success']:
        print(f"公告: {result['notice']}")

    # 2. 获取版本号
    result = verify.get_latest_version()
    if result['success']:
        print(f"最新版本: {result['version']}")

    # 3. 单码登录
    result = verify.login(card, machine_code)
    if result['success']:
        print(f"登录成功! 到期时间: {result['end_time']}")

        # 4. 心跳验证
        result = verify.heartbeat(card, result['statecode'])
        if result['success']:
            print("心跳验证成功")
    else:
        print(f"登录失败: {result['error']}")

if __name__ == '__main__':
    main()

T3 网络验证 WebAPI 开发文档