Metadata-Version: 2.4
Name: kgcaptcha
Version: 1.0.0
Summary: KgCaptcha Python SDK - 凯格验证码服务集成
Author-email: Kyger <dev@kyger.com.cn>
License: MIT License
        
        Copyright (c) 2022 Kyger
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Keywords: captcha,kgcaptcha,验证码,行为验证
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# KgCaptcha SDK

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

## 安装

```bash
pip install kgcaptcha
```

## 快速开始

```python
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 类

#### 初始化

```python
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()** - 发送验证请求

```python
result = captcha.sendRequest()
```

返回结果：
- `result.code`: 状态码，0表示成功
- `result.msg`: 提示信息

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

```python
data = captcha.parse(environ)
```

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

## 许可证

MIT License
