BiliHelper-personal/src/Api/Passport/ApiCaptcha.php
2022-06-03 23:34:44 +08:00

60 lines
1.9 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php declare(strict_types=1);
/**
* Website: https://mudew.com/
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
* Updated: 2022 ~ 2023
*
* _____ _ _ _ _ _ _____ _ _____ _____ _____
* | _ \ | | | | | | | | | | | ____| | | | _ \ | ____| | _ \ & l、
* | |_| | | | | | | | | |_| | | |__ | | | |_| | | |__ | |_| | (゚、 。
* | _ { | | | | | | | _ | | __| | | | ___/ | __| | _ /   \、゙ ~ヽ *
* | |_| | | | | |___ | | | | | | | |___ | |___ | | | |___ | | \ \  じしf_, )
* |_____/ |_| |_____| |_| |_| |_| |_____| |_____| |_| |_____| |_| \_\
*/
namespace Bhp\Api\Passport;
use Bhp\Request\Request;
use Bhp\Sign\Sign;
class ApiCaptcha
{
/**
* @use 获取验证码
* @param int $plat
* @return mixed
*/
public static function combine(int $plat = 3): array
{
$url = 'https://passport.bilibili.com/web/captcha/combine';
$payload = [
'plat' => $plat
];
// {"code":0,"data":{"result":{"success":1,"gt":"b6e5b7fad7ecd37f465838689732e788","challenge":"88148a764f94e5923564b356a69277fc","key":"230509df5ce048ca9bf29e1ee323af30"},"type":1}}
return Request::getJson(true, 'other', $url, $payload);
}
/**
* @use 识别验证码
* @param array $captcha
* @return array
*/
public static function ocr(array $captcha):array{
$url = 'https://captcha-v1.mudew.com:19951/';
$payload = [
'type' => 'gt3',
'gt' => $captcha['gt'],
"challenge" => $captcha['challenge'],
"referer" => "https://passport.bilibili.com/"
];
$headers = [
'Content-Type' => 'application/json',
];
return Request::postJson(true,'other', $url, $payload, $headers);
}
}