Skip to content

Commit

Permalink
Merge branch 'development' of github.com:warifp/nd-captcha
Browse files Browse the repository at this point in the history
  • Loading branch information
warifp committed Jul 23, 2021
2 parents cb8bb03 + 99ff9c7 commit 69ad951
Showing 1 changed file with 1 addition and 57 deletions.
58 changes: 1 addition & 57 deletions examples/nd-captcha.php
Original file line number Diff line number Diff line change
@@ -1,63 +1,7 @@
<?php
require __DIR__ . '/vendor/autoload.php';

use Curl\Curl;

$curl = new Curl();

Class NdCaptcha
{
protected $curl;

public function __construct($key, $pageUrl, $googleKey) {
$this->curl = new Curl();
$this->key = $key;
$this->pageUrl = $pageUrl;
$this->googleKey = $googleKey;
}

public function init() {
$this->curl->get('https://2captcha.com/in.php?key=' . $this->key . '&method=userrecaptcha&googlekey=' . $this->googleKey . '&pageurl=' . $this->pageUrl);

if ($this->curl->error) {
echo 'Error: ' . $this->curl->errorCode . ': ' . $this->curl->errorMessage . "\n";
} else {
$inResponse = explode("|", $this->curl->response);

if ($inResponse[0] == 'OK') {
start:
$this->curl->get('http://2captcha.com/res.php?key=' . $this->key . '&action=get&id=' . $inResponse[1]);

if ($this->curl->error) {
echo 'Error: ' . $this->curl->errorCode . ': ' . $this->curl->errorMessage . "\n";
} else {
$resResponse = explode("|", $this->curl->response);

if($resResponse[0] == 'OK') {
$data = [
'status' => true,
'captcha' => $resResponse[1],
];
} else{
goto start;
}

return $data;
}
} else{
$data = [
'status' => false,
'errors' => [
'path' => 'in',
'message' => $this->curl->response,
],
];
}

return $data;
}
}
}
use NdCaptcha\NdCaptcha;

$recaptcha = new NdCaptcha(
'2CAPTCHA_KEY',
Expand Down

0 comments on commit 69ad951

Please sign in to comment.