reilag/php-anticaptcha
Composer 安装命令:
composer require reilag/php-anticaptcha
包简介
AntiCaptcha - Is PHP Library for working with Anticapthca services
README 文档
README
Anticaptcha PHP SDK
This library will help you to recognize any captcha via specific services.
Easy to install. Easy to use.
packages.org
·
anti-captcha.com
PHP client for anti-captcha.com service. This client supports resolving captcha types:
- Captcha from image
- reCaptcha V2
- Invisible reCaptcha
- reCaptcha V2 Enterprise
- reCaptcha V3
- reCaptcha V3 Enterprise
- Turnstile
To Do:
- FunCaptcha
- GeeTest captcha
- Solving HCaptcha
Install
You can add Anticaptcha as a dependency using the composer.phar CLI:
# Install Composer (if need) curl -sS https://getcomposer.org/installer | php # Add dependency composer require reilag/php-anticaptcha:^2.2.0
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
You can find some examples at /example path.
Create Client
use AntiCaptcha\AntiCaptcha; // Your API key $apiKey = '*********** API_KEY **************'; $antiCaptchaClient = new AntiCaptcha( AntiCaptcha::SERVICE_ANTICAPTCHA, [ 'api_key' => $apiKey, 'debug' => true ] );
Recognize captcha from image
use AntiCaptcha\AntiCaptcha; // Get file content $image = file_get_contents(realpath(dirname(__FILE__)) . '/images/image.jpg'); $imageText = $antiCaptchaClient->recognizeImage($image, null, ['phrase' => 0, 'numeric' => 0], 'en'); echo $imageText;
Recognize reCaptcha V2 (with Proxy or without, Invisible)
$task = new \AntiCaptcha\Task\RecaptchaV2Task( "http://makeawebsitehub.com/recaptcha/test.php", // <-- target website address "6LfI9IsUAAAAAKuvopU0hfY8pWADfR_mogXokIIZ" // <-- recaptcha key from target website ); // Value of 'data-s' parameter. Applies only to Recaptchas on Google web sites. $task->setRecaptchaDataSValue("some data s-value") // Specify whether or not reCaptcha is invisible. This will render an appropriate widget for our workers. $task->setIsInvisible(true); // To use Proxy, use this function $task->setProxy( "8.8.8.8", 1234, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116", "http", "login", "password", // also you can add cookie "cookiename1=cookievalue1; cookiename2=cookievalue2" ); $response = $antiCaptchaClient->recognizeTask($task); echo $response['gRecaptchaResponse'];
Recognize reCaptcha V2 Enterprise (with Proxy or without)
$task = new \AntiCaptcha\Task\RecaptchaV2EnterpriseTask( "http://makeawebsitehub.com/recaptcha/test.php", // <-- target website address "6LfI9IsUAAAAAKuvopU0hfY8pWADfR_mogXokIIZ" // <-- recaptcha key from target website ); // Additional array parameters enterprisePayload $task->setEnterprisePayload([ "s" => "SOME_ADDITIONAL_TOKEN" ]); // To use Proxy $task->setProxy( "8.8.8.8", 1234, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116", "http", "login", "password", // also you can add cookie "cookiename1=cookievalue1; cookiename2=cookievalue2" ); $response = $antiCaptchaClient->recognizeTask($task); echo $response['gRecaptchaResponse'];
Recognize reCaptcha V3 (or V3 Enterprise)
$task = new \AntiCaptcha\Task\RecaptchaV3Task( "http://makeawebsitehub.com/recaptcha/test.php", // target website address "6LfI9IsUAAAAAKuvopU0hfY8pWADfR_mogXokIIZ", // recaptcha key from target website // Filters workers with a particular score. It can have one of the following values: // 0.3, 0.7, 0.9 "0.3" ); // Recaptcha's "action" value. Website owners use this parameter to define what users are doing on the page. $task->setPageAction("myaction"); // As V3 Enterprise is virtually the same as V3 non-Enterprise, we decided to roll out it’s support within the usual V3 tasks. // Set this flag to "true" if you need this V3 solved with Enterprise API. Default value is "false" and // Recaptcha is solved with non-enterprise API. $reCaptchaV3Task->setIsEnterprise(true); $response = $antiCaptchaClient->recognizeTask($task); echo $response['gRecaptchaResponse']; // Return 3AHJ_VuvYIBNBW5yyv0zRYJ75VkOKvhKj9_xGBJKnQimF72rfoq3Iy-DyGHMwLAo6a3
Recognize Turnstile
$task = new \AntiCaptcha\Task\TurnstileTask( // Address of a target web page. Can be located anywhere on the web site, even in a member area. // Our workers don't navigate there but simulate the visit instead. "http://makeawebsitehub.com/recaptcha/test.php", // Turnstile sitekey "6LfI9IsUAAAAAKuvopU0hfY8pWADfR_mogXokIIZ" ); // Optional "action" parameter. $task->setAction("myaction"); // If you need setup proxy $task->setProxy( "8.8.8.8", 1234, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0", "http", "login", "password", null // also you can add cookie ); $response = $antiCaptchaClient->recognizeTask($task); // Token string required for interacting with the submit form on the target website. echo $response['token']; // 0.vtJqmZnvobaUzK2i2PyKaSqHELYtBZfRoPwMvLMdA81WL_9G0vCO3y2VQVIeVplG0mxYF7uX....... // User-Agent of worker's browser. Use it when you submit the response token. echo $response['userAgent']; // Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0
Get balance
use AntiCaptcha\AntiCaptcha; $apiKey = '*********** API_KEY **************'; $service = new \AntiCaptcha\Service\AntiCaptcha($apiKey); $antiCaptchaClient = new \AntiCaptcha\AntiCaptcha($service); echo "Your Balance is: " . $antiCaptchaClient->balance() . "\n";
reilag/php-anticaptcha 适用场景与选型建议
reilag/php-anticaptcha 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 65.42k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2016 年 08 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「antigate」 「rucaptcha」 「anti-captcha」 「anticaptcha」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 reilag/php-anticaptcha 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 reilag/php-anticaptcha 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 reilag/php-anticaptcha 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Lightweight and useful 2captcha.com/rucaptcha.com PHP-client with PSRs support.
Lightweight client for Antigate service
Modern, convenient and full featured anti-captcha.com client library.
Распознавание капч для всех популярных сервисов rucaptcha.com, 2captcha.com, pixodrom.com, captcha24.com, socialink.ru, anti-captcha.com
A Laravel package for captcha recognition for popular services like rucaptcha.com, 2captcha.com, pixodrom.com, captcha24.com, socialink.ru, anti-captcha.com
Alfabank REST API integration
统计信息
- 总下载量: 65.42k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-18