Skip to content

php code

Hi. Please, help me. I've not working with PHP, so I don't know why this code not working for me.

<?php
$captcha = file_get_contents('http://cdn.ttgtmedia.com/digitalguide/images/Misc/');
file_put_contents(__DIR__ . '/captcha.jpg', $captcha);

$fields = array(
    'file' => '@' . __DIR__ . '/captcha.jpg',
    'source_url' => '',
    'captcha_platform' => '',
    'action' => 'Submit'
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1/gsa_test.gsa');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($ch);
curl_close ($ch);

preg_match('/<span id="captcha_result">(.*)<\/span>/', $result, $matches);
echo $matches[1];
return $matches[1];
?>

P.S. Sorry for my bad English.

Comments

Sign In or Register to comment.