php如何实现图形验证码内容?
网友回复
可以使用大模型实现
我们以gemini为例,先注册gemini并获取apikey
composer require google-gemini-php/clientcomposer require guzzlehttp/guzzle
注意,需要php8,1以上的环境才能使用
下面是php调用gemini的api实现问答代码
<?php declare(strict_types=1); require_once '../vendor/autoload.php'; $apiKey = 'AIzaSyAPxxxxxxxxxxxxxxx_uEpw'; $client = \Gemini::client($apiKey); $result = $client->geminiPro()->generateContent('PHP语言是什么?'); echo $result->text() . PHP_EOL;那么验证码图片识别如下:
<?php declare(strict_types=1); require_once '../vendor/autoload.php'; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; $apiKey = 'AIzaSyAPLiuNxxxxxxxxxxxxxxx_uEpw'; $client = \Gemini::factory() ->withApiKey($apiKey) ->withBaseUrl('https://gemini.ailard.com/v1/') ->withHttpClient($client = new \GuzzleHttp\Client([])) ->withStreamHandler(fn(RequestInterface $request): ResponseInterface => $client->send($request, [ 'stream' => true // Allows to provide a custom stream handler for the http client. ])) ->make(); $result = $client ->geminiProVision() ->generateContent([ 'I will provide you with an image CAPTCHA, please recognize the content inside the CAPTCHA and output the text', new \Gemini\Data\Blob( mimeType: \Gemini\Enums\MimeType::IMAGE_JPEG, data: base64_encode( file_get_contents('./captcha01.jpg') ) ) ]); echo $result->text() . PHP_EOL;
听说Gemini 1.5 Flash能根据你的录屏操作网页视频生成Selenium代码?
coze Webhook URL发送触发器报错:{"code":41001004,"data":{"items":[]},"items":[],"message":"RecordNotFound:Pl
sms-activate中的虚拟手机号为啥无法用作google的手机号码验证?
app如何判断自己的网络连接是经过代理传输的?
有没有开源的andriod安卓设备集中管理工具?
acejs如何监听回车并获取上一行文本是否是注释?
SSL证书中OV和DV有啥区别,该如何选择?
python如何批量压缩目录及子目录图片到指定大小内?
google账号如何更改地区与国家?
为啥我的安卓手机chatgpt app打开报错Something went wrong. You may be connected to a disallowed ISP. If you are us