protected function getResponse($request)
{
if ($this->grabberType === self::GRABBER_PHP) {
$response = @file_get_contents($request);
if ($response === false) {
throw new Exception('Unable connection to the captcha server.');
}
} else {
$options = array(CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_POST => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => '', CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120, CURLOPT_MAXREDIRS => 10);
$ch = curl_init($request);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
$err = curl_errno($ch);
$errmsg = curl_error($ch);
$header = curl_getinfo($ch);
curl_close($ch);
$header['errno'] = $err;
$header['errmsg'] = $errmsg;
$response = $content;
if ($header['errno'] !== 0) {
throw new Exception('Unable connection to the captcha server. Curl error #' . $header['errno'] . ' ' . $header['errmsg']);
}
}
return Json::decode($response, true);
}