为什么我会收到此错误:
未定义的变量 key_2captcha
我运行此代码将验证码传递给 2captcha 服务器:
<?php
$id_Captcha=0;
$key_2captcha="key2captcha";
function send_captcha($base_file){
$ch = curl_init("http://2captcha.com/in.php");
curl_setopt($ch, CURLOPT_POSTFIELDS,
array('method'=>"base64",
'key'=>$key_2captcha,
'numeric'=>1,
'max_len'=>1,
'body'=>$base_file,
'submit'=>'download and get the ID'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$postResult = curl_exec($ch);
curl_close($ch);
return $postResult;
}
function getSolveCaptcha($id_captcha){
$c = curl_init("http://2captcha.com/res.php?key=".$key_2captcha."&action=get&id=".$id_captcha);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$postResult = curl_exec($c);
curl_close($c);
return $postResult;
}
?>
我在 XAMPP 中运行此代码。