Skip to main content

KgCaptcha Python SDK - 凯格验证码服务集成

Project description

KgCaptcha SDK

凯格验证码服务 Python SDK,支持行为验证和验证码校验。

安装

pip install kgcaptcha

快速开始

from kgcaptcha import KgCaptcha

# 初始化
captcha = KgCaptcha(appid="你的公钥", secret="你的秘钥")

# 设置参数
captcha.clientIp = "192.168.1.1"  # 客户端IP
captcha.domain = "https://example.com"  # 授权域名
captcha.token = "前端返回的token"  # 前端验证成功后获取的token

# 发送验证请求
result = captcha.sendRequest()

# 处理结果
if result.code == 0:
    print("验证通过")
else:
    print(f"验证失败: {result.msg}")

API 文档

KgCaptcha 类

初始化

captcha = KgCaptcha(appid, secret)
参数 类型 说明
appid str 公钥,从 KgCaptcha 控制台获取
secret str 秘钥,从 KgCaptcha 控制台获取

属性

属性 类型 说明
clientIp str 客户端IP地址
clientBrowser str 浏览器信息
userId str 用户ID
domain str 授权域名
token str 前端验证token
connectTimeout int 连接超时时间(秒),默认50
appCdn str CDN地址,默认 https://cdn.kgcaptcha.com

方法

sendRequest() - 发送验证请求

result = captcha.sendRequest()

返回结果:

  • result.code: 状态码,0表示成功
  • result.msg: 提示信息

parse(environ) - 解析WSGI环境变量

data = captcha.parse(environ)

适用于WSGI服务器,自动提取IP、浏览器、GET/POST参数等。

许可证

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kgcaptcha-1.0.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kgcaptcha-1.0.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file kgcaptcha-1.0.0.tar.gz.

File metadata

  • Download URL: kgcaptcha-1.0.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for kgcaptcha-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2bf49e6db8994ecbffc7101b3ba68fb53a8c464b8444dfcc26688deac616aa21
MD5 9d6d73d11d2b41155bcc3c75f28b1f9e
BLAKE2b-256 8b8b2623c6bd9a4c8fdfc4476b1b69ca2bed8f1438641ff44e2f9fdfa48e0a65

See more details on using hashes here.

File details

Details for the file kgcaptcha-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: kgcaptcha-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for kgcaptcha-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2ceed3c95610af71a4da26e35efc9a2430116260c8efcb605122e6a79fd506e
MD5 fd85ce41f930f2eaf2ec97d4f9e00595
BLAKE2b-256 eb210ad4e902cc524161377d056d38cafb2da797850c9b706c31152f3ce290a0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page