InitFaceVerify.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 InitFaceVerify {
  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. $client = self::createClient(getenv("LTAI4GDXpn5FftNNP1SWardn"), getenv('yLU8B0KaiCwmvgbOKtc5XGxk6Kh1IU'));
  35. // $ReturnUrl = 'http://xiangduilun.hdlkeji.com/app/common/notifyx/type/' . $type.'/orderid/'.$orderId;
  36. $initFaceVerifyRequest = new InitFaceVerifyRequest([
  37. 'SceneId'=>1000007515,
  38. 'OuterOrderNo'=>1,
  39. 'ProductCode'=>'ID_PRO',
  40. 'Model'=>'LIVENESS',
  41. 'CertType'=>'IDENTITY_CARD',
  42. 'CertName'=>$args['CertName'],//真实姓名
  43. 'CertNo'=>$args['CertNo'],//证件号码
  44. 'ReturnUrl'=>$args['ReturnUrl'],
  45. 'MetaInfo'=>$args['MetaInfo']
  46. ]);
  47. $runtime = new RuntimeOptions([]);
  48. try {
  49. // 复制代码运行请自行打印 API 的返回值
  50. $client->initFaceVerifyWithOptions($initFaceVerifyRequest, $runtime);
  51. }
  52. catch (Exception $error) {
  53. if (!($error instanceof TeaError)) {
  54. $error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
  55. }
  56. // 如有需要,请打印 error
  57. Utils::assertAsString($error->message);
  58. }
  59. }
  60. }
  61. $path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
  62. if (file_exists($path)) {
  63. require_once $path;
  64. }
  65. InitFaceVerify::main(array_slice($argv, 1));