lucsaarend/anticaptcha-php

官方 anticaptcha api 实现的 composer-wrapper

1.0.0 2022-12-13 01:40 UTC

This package is auto-updated.

Last update: 2024-09-13 05:20:37 UTC


README

关于包

嘿,欢迎提出改进建议!

原始仓库 GitHub

安装

通过 Composer 获取路由器

"lucsaarend/anticaptcha-php": "^1.0"

或者运行

composer require lucsaarend/anticaptcha-php

文档

支持解决方案

  • AntiGate(在 cloudFlare 网站保护示例中使用)
  • FunCapcha
  • FunCapcha ProxyLess
  • GeeTest
  • GeeTest ProxyLess
  • HCapcha
  • Hcapcha ProxyLess
  • ImageToText
  • RecaptchaV2
  • RecaptchaV2 ProxyLess
  • RecaptchaV2 企业版
  • RecaptchaV2 企业版 ProxyLess
  • RecaptchaV3
  • RecaptchaV3 企业版
  • SquareCaptcha

官方文档 AntiCapcha

设置 API 密钥

#Set Api Key
Suport ENV use ANTICAPTCHA_KEY=YORK_KEY

#Use method setKey
#Example
$apiCaptcha = new AntiGate();
$apiCaptcha->setKey('MyKey');

示例

RecaptchaV2

$apiCaptcha = new RecaptchaV2();
$apiCaptcha->setVerboseMode(true);#Use to debug

//recaptcha key from target website
$apiCaptcha->setWebsiteURL("http://http.myjino.ru/recaptcha/test-get.php");
$apiCaptcha->setWebsiteKey("6Lc_aCMTAAAAABx7u2W0WPXnVbI_v6ZdbM6rYf16");

//browser header parameters
$apiCaptcha->setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0");

if (!$apiCaptcha->createTask()) {
    $apiCaptcha->debout("API v2 send failed - ".$api->getErrorMessage(), "red");
    return false;
}

$taskId = $apiCaptcha->getTaskId();

if (!$apiCaptcha->waitForResult()) {
    $apiCaptcha->debout("could not solve captcha", "red");
    $apiCaptcha->debout($apiCaptcha->getErrorMessage());
} else {
    $recaptchaToken =   $apiCaptcha->getTaskSolution();
    echo "\ntoken result: $recaptchaToken\n\n";
}