说是万能,意思是他支持多种程序语言。而且调用方式也非常简单,当然官方也有例子
Recaptcha,这是一个验证码程序,其实真的很方便,如果你一天到晚还在为着验证码被别人破解而不停的改进自己的验证码时,你可以用它;如果你不会写验证码程序,你可以用它;如果你想支持语音验证,你也可以用它;如果你想有更多的功能,当然你一样可以用它。
使用方法比较简单,大致如下:
- Download the reCAPTCHA Library, unzip it, and copy recaptchalib.php to the directory where your forms live.先到reCAPTCHA下载PHP类库,解压拷到你的线上目录中
- If you haven't done so, sign up for an API key. 准备完后,你可以注册并申请一下API
- Now we're ready to start modifying your code. First, we'll add code to display the CAPTCHA:然后,我们开始修改代码。首先,我们先添加显示CAPTCHA验证码的代码
PHP代码
- require_once('recaptchalib.php');
- $publickey = "..."; // you got this from the signup page,这里就是你刚才申请的API KEY
- echo recaptcha_get_html($publickey);
4.In the code that processes the form submission, you need to add code to validate the CAPTCHA. Otherwise, the CAPTCHA will appear, but the answers won't be checked. The validation code looks like:在提交处理页,你需要添加CAPTCHA验证代码。否则,CAPTCHA并不会验证他们。验证代码大致如下:
- require_once('recaptchalib.php');
- $privatekey = "..."; //申请的API KEY
- $resp = recaptcha_check_answer ($privatekey,
- $_SERVER["REMOTE_ADDR"],
- $_POST["recaptcha_challenge_field"],
- $_POST["recaptcha_response_field"]);
- if (!$resp->is_valid) {
- die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
- "(reCAPTCHA said: " . $resp->error . ")");
- }
看起来是不是很简单?现在是不是不再犹豫了??
更多参考和参数可以查看这里:http://recaptcha.net/plugins/php/