DescribeFaceVerify.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. // This file is auto-generated, don't edit it. Thanks.
  3. namespace app\common\controller;
  4. use AlibabaCloud\SDK\Cloudauth\V20190307\Cloudauth;
  5. use \Exception;
  6. use AlibabaCloud\Tea\Exception\TeaError;
  7. use AlibabaCloud\Tea\Utils\Utils;
  8. use Darabonba\OpenApi\Models\Config;
  9. use AlibabaCloud\SDK\Cloudauth\V20190307\Models\InitFaceVerifyRequest;
  10. use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
  11. class DescribeFaceVerify {
  12. /**
  13. * 使用AK&SK初始化账号Client
  14. * @param string $accessKeyId
  15. * @param string $accessKeySecret
  16. * @return Cloudauth Client
  17. */
  18. public static function createClient($accessKeyId, $accessKeySecret){
  19. $config = new Config([
  20. // 必填,您的 AccessKey ID
  21. "accessKeyId" => $accessKeyId,
  22. // 必填,您的 AccessKey Secret
  23. "accessKeySecret" => $accessKeySecret
  24. ]);
  25. // Endpoint 请参考 https://api.aliyun.com/product/Cloudauth
  26. $config->endpoint = "cloudauth.aliyuncs.com";
  27. return new Cloudauth($config);
  28. }
  29. /**
  30. * @param string[] $args
  31. * @return void
  32. */
  33. public static function main($args){
  34. // 请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID 和 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
  35. // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例使用环境变量获取 AccessKey 的方式进行调用,仅供参考,建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/311677.html
  36. $client = self::createClient(getenv("LTAI4GDXpn5FftNNP1SWardn"), getenv('yLU8B0KaiCwmvgbOKtc5XGxk6Kh1IU'));
  37. $initFaceVerifyRequest = new InitFaceVerifyRequest([]);
  38. $runtime = new RuntimeOptions([
  39. ]);
  40. try {
  41. // 复制代码运行请自行打印 API 的返回值
  42. $client->initFaceVerifyWithOptions($initFaceVerifyRequest, $runtime);
  43. }
  44. catch (Exception $error) {
  45. if (!($error instanceof TeaError)) {
  46. $error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
  47. }
  48. // 如有需要,请打印 error
  49. Utils::assertAsString($error->message);
  50. }
  51. }
  52. }
  53. $path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
  54. if (file_exists($path)) {
  55. require_once $path;
  56. }
  57. DescribeFaceVerify::main(array_slice($argv, 1));