根據(jù) 官方下載頁 拓展,進行下載的二次驗證
要驗證api
此教程簡介:
1、使用阿里云云存儲(會被采集刷下載,刷流量)
2、隱藏下載直鏈(云存儲給的都是直鏈,此插件教程技巧 可以把下載地址隱藏在后端,驗證通過后會進行下載,“防不住有心人,但能防住機器,難破解,難批量獲取”)
3、阿里云存儲開啟防盜鏈(所有的阿里云 云存儲內(nèi)的直鏈下載,只能通過當前域名訪問)

此教程主要配合插件修改下面的模板文件
{dr_down_file($down)} //官方下載標簽模板文件地址:
/template/pc/default/home/api/down_file_msg.html
模板代碼:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Title</title>
<script src="https://static.geetest.com/v4/gt4.js"></script>
<script src="https://apps.bdimg.com/libs/jquery/1.9.1/jquery.js"></script>
<style>
body {
margin: 50px 0;
text-align: center;
}
.btn {
display: inline-block;
box-sizing: border-box;
border: 1px solid #cccccc;
border-radius: 2px;
width: 130px;
height: 40px;
line-height: 40px;
font-size: 16px;
color: #666;
cursor: pointer;
background: white linear-gradient(180deg, #ffffff 0%, #f3f3f3 100%);
}
.btn:hover {
background: white linear-gradient(0deg, #ffffff 0%, #f3f3f3 100%)
}
#captcha {
display: inline-block;
}
</style>
</head>
<body>
<div id="btn" class="btn">點我驗證后下載</div>
<div id="captcha">
</div>
<script>
// 帶* 號 為不可缺少的內(nèi)容
// 此下載提交 只應(yīng)用于官方的下載地址頁面,{dr_down_file($down)}
initGeetest4({
captchaId: "{dr_geetest('xzyz', 2)}",//*對應(yīng)的極驗ID*
product: 'bind',//* 極驗代碼類型,可自行更改
language: "zho",//*驗證碼語言 zho 指的是中文
}, function (gt) {
window.gt = gt;
gt.appendTo("#captcha").onSuccess(function (e) {
//對應(yīng)上方id=captcha 的div控件
var result = gt.getValidate();
var currentUrl = window.location.href;//*獲取當前url地址給變量currenturl*
result.currentUrl = currentUrl;//*傳遞當前頁面url,用來后臺 獲取對應(yīng)的下載id,然后獲取對應(yīng)的下載url*
$.ajax({
url: '../index.php?s=geetest&c=api&m=down&cname={dr_geetest('xzyz', 0)}',//*插件提交頁面,需要后臺對應(yīng)的極驗的別名,用來獲取對應(yīng)id及key*
data: result,
type: 'get',
dataType: 'json',
success: function (res) {
if (res.status === 'success') {
//*判斷后臺傳遞過來的變量,res.status = success 時 會獲取對應(yīng)的下載地址*
window.location.href = res.url;
//1.5秒后關(guān)閉當前頁面
setTimeout(function () {
window.close();
}, 1500);
}
else{
//1秒后如果傳遞過來的不是success ,則跳出彈窗,顯示res.reason 字段,這個一般不會出現(xiàn),出現(xiàn)一般是你網(wǎng)站訪問不了geetest的api服務(wù)器地址,無法通過二次驗證
setTimeout(function () {
alert(res.reason);
}, 1000);
}
}
})
})
$("#btn").click(function(){
gt.showCaptcha();
})
});
</script>
{php exit;}
<!--現(xiàn)階段不可或缺的一句話,不知道后續(xù)官方會不會修復(fù),下載地址如果不用php 手動結(jié)束,會自動執(zhí)行后續(xù)官方的php代碼 有一個跳轉(zhuǎn)msg.html的動作 -->
</body>
</html>演示gif,使用的是綁定按鈕bind形式,請自行更改前端模板,
