当前位置: 首页>>代码示例>>PHP>>正文


PHP ReCaptcha::verify方法代码示例

本文整理汇总了PHP中ReCaptcha::verify方法的典型用法代码示例。如果您正苦于以下问题:PHP ReCaptcha::verify方法的具体用法?PHP ReCaptcha::verify怎么用?PHP ReCaptcha::verify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReCaptcha的用法示例。


在下文中一共展示了ReCaptcha::verify方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testVerifyReturnsResponse

 public function testVerifyReturnsResponse()
 {
     $method = $this->getMock('\\ReCaptcha\\RequestMethod', array('submit'));
     $method->expects($this->once())->method('submit')->with($this->callback(function ($params) {
         return true;
     }))->will($this->returnValue('{"success": true}'));
     $rc = new ReCaptcha('secret', $method);
     $response = $rc->verify('response');
     $this->assertTrue($response->isSuccess());
 }
开发者ID:CuBoulder,项目名称:cu-express-drops-7,代码行数:10,代码来源:ReCaptchaTest.php

示例2: frontend_validate

 /**
  * {@inheritdoc}
  */
 public function frontend_validate(array $item, $input_value)
 {
     $mesages = array('not-configured' => __('Could not validate the form', 'fw'), 'not-human' => __('Please fill the recaptcha', 'fw'));
     $keys = fw_ext('forms')->get_db_settings_option('recaptcha-keys');
     if (empty($keys)) {
         return $mesages['not-configured'];
     }
     $recaptcha = new ReCaptcha($keys['secret-key']);
     $gRecaptchaResponse = FW_Request::POST('g-recaptcha-response');
     if (empty($gRecaptchaResponse)) {
         return $mesages['not-human'];
     }
     $resp = $recaptcha->verify($gRecaptchaResponse);
     if ($resp->isSuccess()) {
         return false;
     } else {
         $errors = $resp->getErrorCodes();
         return $mesages['not-human'];
     }
 }
开发者ID:HilderH,项目名称:emprendamos,代码行数:23,代码来源:class-fw-option-type-form-builder-item-recaptcha.php

示例3: verify_recaptcha

 private function verify_recaptcha($client_ip, $response)
 {
     $rcmail = rcmail::get_instance();
     $privatekey = $rcmail->config->get('recaptcha_privatekey');
     require_once $this->home . '/lib/recaptchalib.php';
     $reCaptcha = new ReCaptcha($privatekey);
     $resp = $reCaptcha->verify($response, $client_ip);
     return $resp != null && $resp->success;
 }
开发者ID:reneschuster,项目名称:plugins,代码行数:9,代码来源:rcguard.php

示例4: ReCaptcha

* \details Pantalla de registro en la aplicación. Añade cabeceras, muestra 
* los mensajes de error de action_register.php y define la estructura del layout.
* \author auth.agoraUS
*/
require_once 'captcha/ReCaptcha.php';
require_once 'captcha/RequestMethod.php';
require_once 'captcha/RequestParameters.php';
require_once 'captcha/Response.php';
require_once 'captcha/RequestMethod/Post.php';
require_once 'captcha/RequestMethod/Socket.php';
require_once 'captcha/RequestMethod/SocketPost.php';
$clave_del_sitio = "6LfD6hcTAAAAAOLQVRMu_oJA4eCRIUxGj0tAo8HJ";
$clave_secreta = "6LfD6hcTAAAAALJdSU9xW9qZfDy0PkvcJLPs7HE4";
if ($_POST['accion'] == 'enviar') {
    $recaptcha = new ReCaptcha($clave_secreta);
    $respuesta = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
    if ($respuesta->isSuccess()) {
        echo 'El formulario ha sido validado';
    } else {
        echo 'Se ha devuelto el siguiente error:';
        foreach ($respuesta->getErrorCodes() as $error_code) {
            echo '<tt>' . $error_code . '</tt> ';
        }
    }
}
include_once "database.php";
session_start();
?>
<!DOCTYPE html>
<html lang="es" xmlns="http://www.w3.org/1999/xhtml">
<head>
开发者ID:AgoraUS1516,项目名称:G03,代码行数:31,代码来源:register.php

示例5: check_captcha

 private function check_captcha()
 {
     if ($this->type == 'create' && $this->captcha) {
         //check if capcha key is set
         $captcha_key = get_option('ihc_recaptcha_public');
         if (!$captcha_key) {
             $captcha = ihc_array_value_exists($this->register_fields, 'recaptcha', 'name');
             unset($this->register_fields[$captcha]);
             return;
         }
         $captcha = ihc_array_value_exists($this->register_fields, 'recaptcha', 'name');
         if ($captcha && $this->register_fields[$captcha]['display']) {
             $captha_err = get_option('ihc_register_err_recaptcha');
             unset($this->register_fields[$captcha]);
             if (isset($_REQUEST['g-recaptcha-response'])) {
                 $secret = get_option('ihc_recaptcha_private');
                 if ($secret) {
                     include_once IHC_PATH . 'classes/ReCaptcha/ReCaptcha.php';
                     $recaptcha = new ReCaptcha($secret);
                     $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
                     if (!$resp->isSuccess()) {
                         $this->errors[] = $captha_err;
                     }
                 } else {
                     $this->errors[] = $captha_err;
                 }
             } else {
                 $this->errors[] = $captha_err;
             }
         }
     }
 }
开发者ID:Juni4567,项目名称:meritscholarship,代码行数:32,代码来源:UserAddEdit.class.php


注:本文中的ReCaptcha::verify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。