Advertisement
kycok12345

Untitled

Jul 16th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. public function testImageToText($url) {
  2.         $api = new ImageToText();
  3.         $api->setVerboseMode(false);
  4.  
  5.         //your anti-captcha.com account key
  6.         $api->setKey("xxxxxxxxxxxxxxxxxxxxxxx");
  7.  
  8.         $path = $_SERVER['DOCUMENT_ROOT'].'/crystal/captcha/' . $api->generateRandomString();
  9.         file_put_contents($path, file_get_contents($url));
  10.  
  11.         //setting file
  12.         $api->setFile($path);
  13.  
  14.         if (!$api->createTask()) {
  15.             $api->debout("API v2 send failed - ".$api->getErrorMessage(), "red");
  16.             return false;
  17.         }
  18.  
  19.         $taskId = $api->getTaskId();
  20.  
  21.         if (!$api->waitForResult()) {
  22.             $api->debout("could not solve captcha", "red");
  23.             $api->debout($api->getErrorMessage());
  24.         } else {
  25.             $captchaText = $api->getTaskSolution();
  26.             return $captchaText;
  27.         }
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement