2016-04-29 13 views
1

Ich habe das neueste recaptcha von google installiert, aber es gibt immer false zurück, nachdem post submit und immer "invalid-input-secret" Fehler zurückgegeben, obwohl die Überprüfung immer korrekt ist von der Frontend-Ansicht. Was könnte der Grund dafür sein? Übrigens teste ich alles in localhost xampp mit Phalcon-Framework. Hier ist der Teil, wo ich das Captcha:google recaptcha gibt false wegen "invalid-input-secret" zurück

protected function validate_data($post, $ip){ 

    $validation = new Validation(); 
    $validation->add(
     'user_name', 
     new PresenceOf(
      array(
       'message' => 'The Username is required' 
      ) 
     ) 
    ); 
    $validation->add(
     'email', 
     new PresenceOf(
      array(
       'message' => 'The e-mail is required' 
      ) 
     ) 
    ); 
    $validation->add(
     'password', 
     new PresenceOf(
      array(
       'message' => 'The Password is required' 
      ) 
     ) 
    ); 
    $validation->add(
     'cpassword', 
     new PresenceOf(
      array(
       'message' => 'The Confirmation Password is required' 
      ) 
     ) 
    ); 
    $validation->add(
     'email', 
     new Email(
      array(
       'message' => 'The e-mail is not valid' 
      ) 
     ) 
    ); 

    $validation->add('password', 
     new Confirmation(array(
      'message' => 'Password doesn\'t match confirmation', 
      'with' => 'cpassword' 
      ) 
     ) 
    ); 

    $error = $validation->validate($post); 
    $errors = array(); 
    if(count($error)){ 
     foreach($error as $e){ 
      $errors[] = $e; 
     } 
    } 

    $data = array(
     'secret' => "my secret key", 
     'response' => $post['g-recaptcha-response'], 
     'remoteip' => $ip 
    ); 

    $verify = curl_init(); 
    curl_setopt($verify, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify"); 
    curl_setopt($verify, CURLOPT_POST, true); 
    curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data)); 
    curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt($verify, CURLOPT_RETURNTRANSFER, true); 
    $res = curl_exec($verify); 

    $captcha = json_decode($res); 

    if($captcha->success == false){ 
     $errors[] = "Invalid Captcha, You are a freakin robot!"; 
    } 

    return $errors; 

} 

was könnte der Grund hier sein? hier ist der Ausgang, wenn Sie die Antwort Dump:

object(stdClass)#70 (2) { ["success"]=> bool(false) ["error-codes"]=> array(1) { [0]=> string(20) "invalid-input-secret" } } 
+0

Wer kennt das schon mal? – MusicManDev

Antwort

5

Dumme mich, ich verdoppelte den geheimen Schlüssel überprüfen, und es wurde nur ein einzelnes Zeichen am Anfang fehlt. Das hat es gelöst.

+3

das scheint ein Problem mit Googles Recaptcha-Seite zu sein, weil das selbe mit mir zweimal passiert ist .. der erste Charakter hat nicht kopiert – sohaiby

+0

Stimme hier völlig mit @sohaiby überein. In meinem Fall wurde das letzte Zeichen nicht mit einem Doppelklick kopiert. –