烽火星空 2018-03-29 08:39:29 6518次浏览 3条评论 7 3 0

这是基于yii2的AR封装的验证码使用规范,只要简单配置几个参数就能实现验证码的接入。

使用方法

1.视图调用

<?=$form->field($model,'yanCaptchaValidate')->widget(\webroot\common\widgets\yanCaptcha\YanCaptchaWidget::className(),[
      'app_id'=>xxx,
      'pattern'=>'static',
      'width'=>300,
    'api_server'=>'api.yanphp.com'
])->label(false)?>

2.服务端二次验证

public function rules()
{
    return [
        ['name','required'],
        ['yanCaptchaValidate','required'],
        ['yanCaptchaValidate',YanCaptchaValidator::className(),
            'app_id'=>xxx,
            'secret'=>'xxx',
            'api_server'=>'http://api.yanphp.com/dun/v1/verify',
            'message'=>'验证失败'
        ],
 
    ];
}

参数说明

具体参数请参考http://www.yanphp.com/show20

觉得很赞
您需要登录后才可以评论。登录 | 立即注册