This article mainly introduces the method of integrating Geetestverification codewith Laravel. It has a certain reference value. Now I share it with you. Friends in need can refer to it
Geetest integration process
The rough logic of logging in
Register a Geetest account
Register a behavioral verification in the background management of "JiXian"
Configure ourcontroller according to the official Demoand routing
Configure our login template according to the official Demo
Test
##Geetest integration detailed process
1. Implement the general logic of login Create the controller php artisan make:controller GeetestControllerCopy after login
captchaId, $this->privateKey); session_start(); $data = array( "user_id" => "test", # 网站用户id "client_type" => "web", #web:电脑上的浏览器;h5:手机上的浏览器,包括移动应用内完全内置的web_view;native:通过原生SDK植入APP应用的方式 "ip_address" => "127.0.0.1" # 请在此处传输用户请求验证时所携带的IP ); $status = $GtSdk->pre_process($data, 1); $_SESSION['gtserver'] = $status; $_SESSION['user_id'] = $data['user_id']; echo $GtSdk->get_response_str(); } }
// 集成 Geetest 验证码 Route::get('GeetestLogin', 'GeetestController@login'); //登录页面 Route::get('GeetestCheck', 'GeetestController@check'); //登录验证 (我们没写具体逻辑) Route::get('GeetestStartCaptchaServlet', 'GeetestController@startCaptchaServlet'); // 调用方法启用验证码
resources/views/Geetest/login.blade.php
Need to import jquery (we use npm run dev compiled app.js to integrate jquery)Geetest 集成 Demo
Geetest 集成 Demo Geetest 官方网站
Test successful
Area that can be optimized It is best not to use a "controller" as the core class library. You should find a way to integrate GeetestLib into another placeLaravel framework implements the model layer Example of CURD operation
The above is the detailed content of How to integrate Geetest verification code with Laravel. For more information, please follow other related articles on the PHP Chinese website!