|
11 | 11 | use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\CheckResultResponse; |
12 | 12 | use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\CheckVerifyLogRequest; |
13 | 13 | use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\CheckVerifyLogResponse; |
| 14 | +use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\CredentialVerifyIntlAdvanceRequest; |
| 15 | +use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\CredentialVerifyIntlRequest; |
| 16 | +use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\CredentialVerifyIntlResponse; |
14 | 17 | use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\DeepfakeDetectIntlRequest; |
15 | 18 | use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\DeepfakeDetectIntlResponse; |
16 | 19 | use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\DeleteVerifyResultRequest; |
|
36 | 39 | use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\InitializeShrinkRequest; |
37 | 40 | use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\Mobile3MetaVerifyIntlRequest; |
38 | 41 | use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\Mobile3MetaVerifyIntlResponse; |
| 42 | +use AlibabaCloud\SDK\OpenPlatform\V20191219\Models\AuthorizeFileUploadRequest; |
| 43 | +use AlibabaCloud\SDK\OpenPlatform\V20191219\Models\AuthorizeFileUploadResponse; |
| 44 | +use AlibabaCloud\SDK\OpenPlatform\V20191219\OpenPlatform; |
| 45 | +use AlibabaCloud\SDK\OSS\OSS; |
| 46 | +use AlibabaCloud\SDK\OSS\OSS\PostObjectRequest; |
| 47 | +use AlibabaCloud\SDK\OSS\OSS\PostObjectRequest\header; |
| 48 | +use AlibabaCloud\Tea\FileForm\FileForm\FileField; |
| 49 | +use Darabonba\OpenApi\Models\Config; |
39 | 50 | use Darabonba\OpenApi\Models\OpenApiRequest; |
40 | 51 | use Darabonba\OpenApi\Models\Params; |
41 | 52 | use Darabonba\OpenApi\OpenApiClient; |
@@ -306,6 +317,162 @@ public function checkVerifyLog($request) |
306 | 317 | return $this->checkVerifyLogWithOptions($request, $runtime); |
307 | 318 | } |
308 | 319 |
|
| 320 | + /** |
| 321 | + * 凭证核验. |
| 322 | + * |
| 323 | + * @param request - CredentialVerifyIntlRequest |
| 324 | + * @param runtime - runtime options for this request RuntimeOptions |
| 325 | + * |
| 326 | + * @returns CredentialVerifyIntlResponse |
| 327 | + * |
| 328 | + * @param CredentialVerifyIntlRequest $request |
| 329 | + * @param RuntimeOptions $runtime |
| 330 | + * |
| 331 | + * @return CredentialVerifyIntlResponse |
| 332 | + */ |
| 333 | + public function credentialVerifyIntlWithOptions($request, $runtime) |
| 334 | + { |
| 335 | + $request->validate(); |
| 336 | + $query = []; |
| 337 | + if (null !== $request->credName) { |
| 338 | + @$query['CredName'] = $request->credName; |
| 339 | + } |
| 340 | + |
| 341 | + if (null !== $request->credType) { |
| 342 | + @$query['CredType'] = $request->credType; |
| 343 | + } |
| 344 | + |
| 345 | + if (null !== $request->imageUrl) { |
| 346 | + @$query['ImageUrl'] = $request->imageUrl; |
| 347 | + } |
| 348 | + |
| 349 | + if (null !== $request->productCode) { |
| 350 | + @$query['ProductCode'] = $request->productCode; |
| 351 | + } |
| 352 | + |
| 353 | + $body = []; |
| 354 | + if (null !== $request->imageFile) { |
| 355 | + @$body['ImageFile'] = $request->imageFile; |
| 356 | + } |
| 357 | + |
| 358 | + $req = new OpenApiRequest([ |
| 359 | + 'query' => Utils::query($query), |
| 360 | + 'body' => Utils::parseToMap($body), |
| 361 | + ]); |
| 362 | + $params = new Params([ |
| 363 | + 'action' => 'CredentialVerifyIntl', |
| 364 | + 'version' => '2022-08-09', |
| 365 | + 'protocol' => 'HTTPS', |
| 366 | + 'pathname' => '/', |
| 367 | + 'method' => 'POST', |
| 368 | + 'authType' => 'AK', |
| 369 | + 'style' => 'RPC', |
| 370 | + 'reqBodyType' => 'formData', |
| 371 | + 'bodyType' => 'json', |
| 372 | + ]); |
| 373 | + |
| 374 | + return CredentialVerifyIntlResponse::fromMap($this->callApi($params, $req, $runtime)); |
| 375 | + } |
| 376 | + |
| 377 | + /** |
| 378 | + * 凭证核验. |
| 379 | + * |
| 380 | + * @param request - CredentialVerifyIntlRequest |
| 381 | + * |
| 382 | + * @returns CredentialVerifyIntlResponse |
| 383 | + * |
| 384 | + * @param CredentialVerifyIntlRequest $request |
| 385 | + * |
| 386 | + * @return CredentialVerifyIntlResponse |
| 387 | + */ |
| 388 | + public function credentialVerifyIntl($request) |
| 389 | + { |
| 390 | + $runtime = new RuntimeOptions([]); |
| 391 | + |
| 392 | + return $this->credentialVerifyIntlWithOptions($request, $runtime); |
| 393 | + } |
| 394 | + |
| 395 | + /** |
| 396 | + * @param CredentialVerifyIntlAdvanceRequest $request |
| 397 | + * @param RuntimeOptions $runtime |
| 398 | + * |
| 399 | + * @return CredentialVerifyIntlResponse |
| 400 | + */ |
| 401 | + public function credentialVerifyIntlAdvance($request, $runtime) |
| 402 | + { |
| 403 | + // Step 0: init client |
| 404 | + $accessKeyId = $this->_credential->getAccessKeyId(); |
| 405 | + $accessKeySecret = $this->_credential->getAccessKeySecret(); |
| 406 | + $securityToken = $this->_credential->getSecurityToken(); |
| 407 | + $credentialType = $this->_credential->getType(); |
| 408 | + $openPlatformEndpoint = $this->_openPlatformEndpoint; |
| 409 | + if (null === $openPlatformEndpoint) { |
| 410 | + $openPlatformEndpoint = 'openplatform.aliyuncs.com'; |
| 411 | + } |
| 412 | + |
| 413 | + if (null === $credentialType) { |
| 414 | + $credentialType = 'access_key'; |
| 415 | + } |
| 416 | + |
| 417 | + $authConfig = new Config([ |
| 418 | + 'accessKeyId' => $accessKeyId, |
| 419 | + 'accessKeySecret' => $accessKeySecret, |
| 420 | + 'securityToken' => $securityToken, |
| 421 | + 'type' => $credentialType, |
| 422 | + 'endpoint' => $openPlatformEndpoint, |
| 423 | + 'protocol' => $this->_protocol, |
| 424 | + 'regionId' => $this->_regionId, |
| 425 | + ]); |
| 426 | + $authClient = new OpenPlatform($authConfig); |
| 427 | + $authRequest = new AuthorizeFileUploadRequest([ |
| 428 | + 'product' => 'Cloudauth-intl', |
| 429 | + 'regionId' => $this->_regionId, |
| 430 | + ]); |
| 431 | + $authResponse = new AuthorizeFileUploadResponse([]); |
| 432 | + $ossConfig = new OSS\Config([ |
| 433 | + 'accessKeyId' => $accessKeyId, |
| 434 | + 'accessKeySecret' => $accessKeySecret, |
| 435 | + 'type' => 'access_key', |
| 436 | + 'protocol' => $this->_protocol, |
| 437 | + 'regionId' => $this->_regionId, |
| 438 | + ]); |
| 439 | + $ossClient = new OSS($ossConfig); |
| 440 | + $fileObj = new FileField([]); |
| 441 | + $ossHeader = new header([]); |
| 442 | + $uploadRequest = new PostObjectRequest([]); |
| 443 | + $ossRuntime = new \AlibabaCloud\Tea\OSSUtils\OSSUtils\RuntimeOptions([]); |
| 444 | + Utils::convert($runtime, $ossRuntime); |
| 445 | + $credentialVerifyIntlReq = new CredentialVerifyIntlRequest([]); |
| 446 | + Utils::convert($request, $credentialVerifyIntlReq); |
| 447 | + if (null !== $request->imageFileObject) { |
| 448 | + $authResponse = $authClient->authorizeFileUploadWithOptions($authRequest, $runtime); |
| 449 | + $ossConfig->accessKeyId = $authResponse->body->accessKeyId; |
| 450 | + $ossConfig->endpoint = Utils::getEndpoint($authResponse->body->endpoint, $authResponse->body->useAccelerate, $this->_endpointType); |
| 451 | + $ossClient = new OSS($ossConfig); |
| 452 | + $fileObj = new FileField([ |
| 453 | + 'filename' => $authResponse->body->objectKey, |
| 454 | + 'content' => $request->imageFileObject, |
| 455 | + 'contentType' => '', |
| 456 | + ]); |
| 457 | + $ossHeader = new header([ |
| 458 | + 'accessKeyId' => $authResponse->body->accessKeyId, |
| 459 | + 'policy' => $authResponse->body->encodedPolicy, |
| 460 | + 'signature' => $authResponse->body->signature, |
| 461 | + 'key' => $authResponse->body->objectKey, |
| 462 | + 'file' => $fileObj, |
| 463 | + 'successActionStatus' => '201', |
| 464 | + ]); |
| 465 | + $uploadRequest = new PostObjectRequest([ |
| 466 | + 'bucketName' => $authResponse->body->bucket, |
| 467 | + 'header' => $ossHeader, |
| 468 | + ]); |
| 469 | + $ossClient->postObject($uploadRequest, $ossRuntime); |
| 470 | + $credentialVerifyIntlReq->imageFile = 'http://' . $authResponse->body->bucket . '.' . $authResponse->body->endpoint . '/' . $authResponse->body->objectKey . ''; |
| 471 | + } |
| 472 | + |
| 473 | + return $this->credentialVerifyIntlWithOptions($credentialVerifyIntlReq, $runtime); |
| 474 | + } |
| 475 | + |
309 | 476 | /** |
310 | 477 | * 人脸凭证核验. |
311 | 478 | * |
|
0 commit comments