pikpak‐获取邮箱验证码接口 - LiJunYi2/pikpak GitHub Wiki
pikpak-获取邮箱验证码接口
获取邮箱接口请求时间已提升至30s ,30s内未获取到则返回:
{"code": 500, "verification_code": "", "msg": "没有获取到验证码..."}
纸鸢接口调整示例:,server_type:请求登录邮箱的方式,默认是pop3,可以不传此参数。对于qq、foxmail 可以设定为imap。其他的目前仅使用pop3
def get_verification_code(email, password):
url = "https://ppcode.bilivo.top/get_code"
payload = {
"email": email,
"password": password,
"recipientEmail": email,
"server_type": "pop3"
}
headers = {"content-type": "application/json"}
response = requests.request("POST", url, json=payload, headers=headers)
res_json = json.loads(response.text)
print(res_json)
if "verification_code" in res_json.keys():
return res_json['verification_code']
else:
return get_verification_code(email, password)
邮箱兼容
- outlook
- hotmail
- foxmail
- 163
- gmail
参数解释
- userName:邮箱用户名
- passWord:邮箱pop或者Imap授权码,看你server_type传的是啥就用啥授权码!目前闪邮箱提取的 outlook 默认都是用的 pop3 进行登录
- sender_email:邮件发送者,可以不传,就是读取谁发来的邮件,默认 pikpak 官方
- recipientEmail:一般情况下等同于userName。就是看你代码里发送邮件时的名称。有这个参数是因为,一个 outlook 账号,可以生成 10 个别名,当你用别名去邀请注册时,recipientEmail填写的是你别名邮箱名称,userName填写的就是你主号邮箱名称
- server_type:登录邮箱的方式,对于qq、gmail、163可以设定为imap。outlook目前仅使用pop3
server_type:登录邮箱的方式,对于qq、gmail、163可以设定为imap。outlook目前仅使用pop3
自用代码示例
def get_verification_code(email, password):
request_data = {
"userName": email,
"passWord": password,
"recipientEmail": email
}
# 发送 POST 请求
response = requests.post('https://ppcode.bilivo.top/get_code', json=request_data)
# 检查响应状态码
if response.status_code == 200:
response_json = response.json()
if response_json.get('code') == 200:
return response_json.get('verification_code')
return None
接口URL
请求方式
POST
Content-Type
json
请求Body参数
{
"userName": "[email protected]",
"passWord": "123456",
"sender_email": "[email protected]",
"recipientEmail": "[email protected]",
"server_type": "imap"
}
参数名 | 示例值 | 参数类型 | 是否必填 | 参数描述 |
---|---|---|---|---|
userName | [email protected] | String | 是 | outlook用户名 |
passWord | 123456 | String | 是 | outlook密码 |
sender_email | [email protected] | String | 否 | 发件人邮箱地址 |
recipientEmail | [email protected] | String | 否 | 收件人邮箱,一般同outlook用户名,适用于一个主 outlook 下的别名邮箱获取邮件 |
server_type | imap | String | 否 | 请求登录邮箱类型,默认 pop3,如需 imap 需要手动设置,而且,imap 仅支持163、qq、gmail |
响应示例
- 成功(200)
{
"code": 200,
"verification_code": "401145",
"msg": "success"
}
- 失败(500)
{
"code": 500,
"verification_code": " ",
"msg": "没有获取到验证码..."
}
- 无法登录(500)
{
"code": 500,
"msg": "多次尝试连接到邮件服务器失败...",
"verification_code": ""
}