title: PHP - Validate the recaptcha v2 response
body: <pre><code>#form.php
  
  if(isset($_POST['g-recaptcha-response'])){
      $captcha=$_POST['g-recaptcha-response'];
      $captcha=$_GET["g-recaptcha-response"];
      $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=__1234__&amp;response=".$captcha."&amp;remoteip=".$_SERVER['REMOTE_ADDR']);
  
      echo $response;
  </code></pre>
  
  <p>Returns:</p>
  
  <blockquote>
    <p>Notice: Undefined index: g-recaptcha-response in /var/www/clients/qmax/app/controllers/job_application_controller.php on line 114 { "success": false, "error-codes": [ "missing-input-response" ] }</p>
  </blockquote>
  
  <pre><code>echo $response-&gt;success;
  </code></pre>
  
  <p>Returns:</p>
  
  <blockquote>
    <p>Notice: Trying to get property of non-object in /var/www/clients/qmax/app/controllers/job_application_controller.php on line 119</p>
  </blockquote>
  
  <p>I just need to get the "success" object, then I can test if it is True OR False and I am done. </p>