For smart Primates & ROBOTS (oh and ALIENS ).

Thursday, March 12, 2015

reCAPTCHA

Google has improvement it's captcha and introduced new reCAPTCHA


reCAPTCHA 















Follow below steps to implement reCAPTCHA:

1- Sign up google reCAPTCHA site:
http://www.google.com/recaptcha/intro/index.html

2- Register your site domain. after thar it will give you "site key" and "secret key"

ON CLIENT SITE:

1- Paste this line in your web page.
<script src='https://www.google.com/recaptcha/api.js'></script>

2- Paste the <div> tag as same in reCaptcha site:
<div class="g-recaptcha" data-sitekey="YOUR-SITE-KEY"></div> 

ON SERVER SITE:

1-  Send three variable as POST method to url  
https://www.google.com/recaptcha/api/siteverify

Post variable are: secret, response, remoteip
where secret is the your Secret Key
response is recaptcha
remoteip is your remote ip address

//CHECK reCAPTCHA in PHP code
$g_r_r=$POST['g-recaptcha-response'];
if(!empty($g_r_r) && strlen($g_r_r)>0) { 
  $gurl="https://www.google.com/recaptcha/api/siteverify";
  $scrt='YOUR-SECRET KEY';
  $my_ip=$_SERVER['REMOTE_ADDR'];
  $url=$gurl."?secret=".$
scrt."&response=".$g_r_r."&remoteip=".$my_ip;
  
  $c = curl_init();
  curl_setopt($c, CURLOPT_URL, $url);
  curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($c, CURLOPT_TIMEOUT, 30);
  curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16");

  $c_data = curl_exec($c);
  curl_close($c);
  $res= json_decode($c_data , true);
  if($res['success']>=1) {
    //IMPLEMENT HERE LOGIN LOGIC OR ANY OTHER LOGIC
  }
}
Share:

0 comments:

Post a Comment

Featured Post

Core Web Vitals Assessment showing LCP 10.6s while google pagespeed report showing LCP 3.5s why?

Core Web Vitals Assessment showing LCP 10.6s while google pagespeed report showing LCP 3.5s why? So, you can face this situation while...

Ads Inside Post

Powered by Blogger.

Arsip

Blog Archive