在開發過程中,我發現傳統的驗證碼系統無法滿足我的需求,因為它們不僅用戶體驗差,而且對機器人攻擊的防護效果有限。經過一番研究,我決定使用 Google Cloud Recaptcha Enterprise 來提升網站的安全性和用戶體驗。
安裝 Google Cloud Recaptcha Enterprise 非常簡單,只需使用 composer 即可:
$ composer require google/cloud-recaptcha-enterprise
安裝完成后,你需要進行身份驗證,具體步驟請參考 Google Cloud 的身份驗證指南。一旦完成身份驗證,你就可以開始使用這個強大的工具了。
以下是一個簡單的示例代碼,展示如何創建一個新的 Recaptcha 密鑰:
require 'vendor/autoload.php'; use GoogleCloudRecaptchaEnterpriseV1Key; use GoogleCloudRecaptchaEnterpriseV1RecaptchaEnterpriseServiceClient; use GoogleCloudRecaptchaEnterpriseV1WebKeySettings; use GoogleCloudRecaptchaEnterpriseV1WebKeySettingsIntegrationType; $client = new RecaptchaEnterpriseServiceClient(); $project = RecaptchaEnterpriseServiceClient::projectName('[MY_PROJECT_ID]'); $webKeySettings = (new WebKeySettings()) ->setAllowedDomains(['example.com']) ->setAllowAmpTraffic(false) ->setIntegrationType(IntegrationType::CHECKBOX); $key = (new Key()) ->setWebSettings($webKeySettings) ->setDisplayName('my sample key') ->setName('my_key'); $response = $client->createKey($project, $key); printf('Created key: %s' . PHP_EOL, $response->getName());
Google Cloud Recaptcha Enterprise 不僅支持 REST 接口,還支持 gRPC,這使得它在處理大規模請求時更加高效。此外,它還提供了豐富的 API 文檔和調試指南,幫助開發者快速上手和解決問題。
使用 Google Cloud Recaptcha Enterprise 后,我的網站安全性得到了顯著提升,機器人攻擊大幅減少,用戶體驗也得到了改善。這個工具不僅解決了我的實際問題,還為未來的開發提供了堅實的安全保障。
總的來說,Google Cloud Recaptcha Enterprise 是一個強大且易用的安全驗證解決方案,非常適合需要高效防護機器人攻擊的網站開發者。如果你也面臨類似的安全問題,不妨嘗試一下這個工具。
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END