google/cloud-recaptcha-enterprise

Google Cloud Recaptcha Enterprise PHP客户端

v1.15.0 2024-08-30 22:10 UTC

README

这是Google Cloud Recaptcha Enterprise的PHP语言的惯用客户端,[链接](https://cloud.google.com/recaptcha-enterprise)。

Latest Stable Version Packagist

注意: 此存储库是Google Cloud PHP的一部分。任何支持请求、错误报告或开发贡献应直接提交给该项目。

安装

首先,安装PHP的首选依赖管理器Composer

现在安装此组件

$ composer require google/cloud-recaptcha-enterprise

此组件支持HTTP/1.1上的REST和gRPC。要利用gRPC(例如流方法)提供的优势,请参阅我们的gRPC安装指南

身份验证

有关如何对客户端进行身份验证的更多信息,请参阅我们的身份验证指南。一旦完成身份验证,您就可以开始进行请求。

示例

require 'vendor/autoload.php';

use Google\Cloud\RecaptchaEnterprise\V1\Key;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
use Google\Cloud\RecaptchaEnterprise\V1\WebKeySettings;
use Google\Cloud\RecaptchaEnterprise\V1\WebKeySettings\IntegrationType;


$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());

版本

此组件被认为是GA(普遍可用)。因此,它不会在任何次要或修补版本中引入不兼容的更改。我们将优先处理问题和请求。

下一步

  1. 了解官方文档