|
36 | 36 | use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\CredentialVerifyIntlResponse; |
37 | 37 | use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\DeepfakeDetectIntlRequest; |
38 | 38 | use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\DeepfakeDetectIntlResponse; |
| 39 | +use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\DeepfakeDetectIntlStreamAdvanceRequest; |
| 40 | +use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\DeepfakeDetectIntlStreamRequest; |
| 41 | +use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\DeepfakeDetectIntlStreamResponse; |
39 | 42 | use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\DeleteFaceGroupRequest; |
40 | 43 | use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\DeleteFaceGroupResponse; |
41 | 44 | use AlibabaCloud\SDK\Cloudauthintl\V20220809\Models\DeleteFaceRecordRequest; |
@@ -1237,6 +1240,179 @@ public function deepfakeDetectIntl($request) |
1237 | 1240 | return $this->deepfakeDetectIntlWithOptions($request, $runtime); |
1238 | 1241 | } |
1239 | 1242 |
|
| 1243 | + /** |
| 1244 | + * deepfake文件流api. |
| 1245 | + * |
| 1246 | + * @param Request - DeepfakeDetectIntlStreamRequest |
| 1247 | + * @param runtime - runtime options for this request RuntimeOptions |
| 1248 | + * |
| 1249 | + * @returns DeepfakeDetectIntlStreamResponse |
| 1250 | + * |
| 1251 | + * @param DeepfakeDetectIntlStreamRequest $request |
| 1252 | + * @param RuntimeOptions $runtime |
| 1253 | + * |
| 1254 | + * @return DeepfakeDetectIntlStreamResponse |
| 1255 | + */ |
| 1256 | + public function deepfakeDetectIntlStreamWithOptions($request, $runtime) |
| 1257 | + { |
| 1258 | + $request->validate(); |
| 1259 | + $body = []; |
| 1260 | + if (null !== $request->faceBase64) { |
| 1261 | + @$body['FaceBase64'] = $request->faceBase64; |
| 1262 | + } |
| 1263 | + |
| 1264 | + if (null !== $request->faceFile) { |
| 1265 | + @$body['FaceFile'] = $request->faceFile; |
| 1266 | + } |
| 1267 | + |
| 1268 | + if (null !== $request->faceInputType) { |
| 1269 | + @$body['FaceInputType'] = $request->faceInputType; |
| 1270 | + } |
| 1271 | + |
| 1272 | + if (null !== $request->faceUrl) { |
| 1273 | + @$body['FaceUrl'] = $request->faceUrl; |
| 1274 | + } |
| 1275 | + |
| 1276 | + if (null !== $request->merchantBizId) { |
| 1277 | + @$body['MerchantBizId'] = $request->merchantBizId; |
| 1278 | + } |
| 1279 | + |
| 1280 | + if (null !== $request->productCode) { |
| 1281 | + @$body['ProductCode'] = $request->productCode; |
| 1282 | + } |
| 1283 | + |
| 1284 | + if (null !== $request->sceneCode) { |
| 1285 | + @$body['SceneCode'] = $request->sceneCode; |
| 1286 | + } |
| 1287 | + |
| 1288 | + $req = new OpenApiRequest([ |
| 1289 | + 'body' => Utils::parseToMap($body), |
| 1290 | + ]); |
| 1291 | + $params = new Params([ |
| 1292 | + 'action' => 'DeepfakeDetectIntlStream', |
| 1293 | + 'version' => '2022-08-09', |
| 1294 | + 'protocol' => 'HTTPS', |
| 1295 | + 'pathname' => '/', |
| 1296 | + 'method' => 'POST', |
| 1297 | + 'authType' => 'AK', |
| 1298 | + 'style' => 'RPC', |
| 1299 | + 'reqBodyType' => 'formData', |
| 1300 | + 'bodyType' => 'json', |
| 1301 | + ]); |
| 1302 | + |
| 1303 | + return DeepfakeDetectIntlStreamResponse::fromMap($this->callApi($params, $req, $runtime)); |
| 1304 | + } |
| 1305 | + |
| 1306 | + /** |
| 1307 | + * deepfake文件流api. |
| 1308 | + * |
| 1309 | + * @param Request - DeepfakeDetectIntlStreamRequest |
| 1310 | + * |
| 1311 | + * @returns DeepfakeDetectIntlStreamResponse |
| 1312 | + * |
| 1313 | + * @param DeepfakeDetectIntlStreamRequest $request |
| 1314 | + * |
| 1315 | + * @return DeepfakeDetectIntlStreamResponse |
| 1316 | + */ |
| 1317 | + public function deepfakeDetectIntlStream($request) |
| 1318 | + { |
| 1319 | + $runtime = new RuntimeOptions([]); |
| 1320 | + |
| 1321 | + return $this->deepfakeDetectIntlStreamWithOptions($request, $runtime); |
| 1322 | + } |
| 1323 | + |
| 1324 | + /** |
| 1325 | + * @param DeepfakeDetectIntlStreamAdvanceRequest $request |
| 1326 | + * @param RuntimeOptions $runtime |
| 1327 | + * |
| 1328 | + * @return DeepfakeDetectIntlStreamResponse |
| 1329 | + */ |
| 1330 | + public function deepfakeDetectIntlStreamAdvance($request, $runtime) |
| 1331 | + { |
| 1332 | + // Step 0: init client |
| 1333 | + if (null === $this->_credential) { |
| 1334 | + throw new ClientException([ |
| 1335 | + 'code' => 'InvalidCredentials', |
| 1336 | + 'message' => 'Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details.', |
| 1337 | + ]); |
| 1338 | + } |
| 1339 | + |
| 1340 | + $credentialModel = $this->_credential->getCredential(); |
| 1341 | + $accessKeyId = $credentialModel->accessKeyId; |
| 1342 | + $accessKeySecret = $credentialModel->accessKeySecret; |
| 1343 | + $securityToken = $credentialModel->securityToken; |
| 1344 | + $credentialType = $credentialModel->type; |
| 1345 | + $openPlatformEndpoint = $this->_openPlatformEndpoint; |
| 1346 | + if (null === $openPlatformEndpoint || '' == $openPlatformEndpoint) { |
| 1347 | + $openPlatformEndpoint = 'openplatform.aliyuncs.com'; |
| 1348 | + } |
| 1349 | + |
| 1350 | + if (null === $credentialType) { |
| 1351 | + $credentialType = 'access_key'; |
| 1352 | + } |
| 1353 | + |
| 1354 | + $authConfig = new Config([ |
| 1355 | + 'accessKeyId' => $accessKeyId, |
| 1356 | + 'accessKeySecret' => $accessKeySecret, |
| 1357 | + 'securityToken' => $securityToken, |
| 1358 | + 'type' => $credentialType, |
| 1359 | + 'endpoint' => $openPlatformEndpoint, |
| 1360 | + 'protocol' => $this->_protocol, |
| 1361 | + 'regionId' => $this->_regionId, |
| 1362 | + ]); |
| 1363 | + $authClient = new OpenApiClient($authConfig); |
| 1364 | + $authRequest = [ |
| 1365 | + 'Product' => 'Cloudauth-intl', |
| 1366 | + 'RegionId' => $this->_regionId, |
| 1367 | + ]; |
| 1368 | + $authReq = new OpenApiRequest([ |
| 1369 | + 'query' => Utils::query($authRequest), |
| 1370 | + ]); |
| 1371 | + $authParams = new Params([ |
| 1372 | + 'action' => 'AuthorizeFileUpload', |
| 1373 | + 'version' => '2019-12-19', |
| 1374 | + 'protocol' => 'HTTPS', |
| 1375 | + 'pathname' => '/', |
| 1376 | + 'method' => 'GET', |
| 1377 | + 'authType' => 'AK', |
| 1378 | + 'style' => 'RPC', |
| 1379 | + 'reqBodyType' => 'formData', |
| 1380 | + 'bodyType' => 'json', |
| 1381 | + ]); |
| 1382 | + $authResponse = []; |
| 1383 | + $fileObj = new FileField([]); |
| 1384 | + $ossHeader = []; |
| 1385 | + $tmpBody = []; |
| 1386 | + $useAccelerate = false; |
| 1387 | + $authResponseBody = []; |
| 1388 | + $deepfakeDetectIntlStreamReq = new DeepfakeDetectIntlStreamRequest([]); |
| 1389 | + Utils::convert($request, $deepfakeDetectIntlStreamReq); |
| 1390 | + if (null !== $request->faceFileObject) { |
| 1391 | + $authResponse = $authClient->callApi($authParams, $authReq, $runtime); |
| 1392 | + $tmpBody = @$authResponse['body']; |
| 1393 | + $useAccelerate = (bool) (@$tmpBody['UseAccelerate']); |
| 1394 | + $authResponseBody = Utils::stringifyMapValue($tmpBody); |
| 1395 | + $fileObj = new FileField([ |
| 1396 | + 'filename' => @$authResponseBody['ObjectKey'], |
| 1397 | + 'content' => $request->faceFileObject, |
| 1398 | + 'contentType' => '', |
| 1399 | + ]); |
| 1400 | + $ossHeader = [ |
| 1401 | + 'host' => '' . @$authResponseBody['Bucket'] . '.' . Utils::getEndpoint(@$authResponseBody['Endpoint'], $useAccelerate, $this->_endpointType) . '', |
| 1402 | + 'OSSAccessKeyId' => @$authResponseBody['AccessKeyId'], |
| 1403 | + 'policy' => @$authResponseBody['EncodedPolicy'], |
| 1404 | + 'Signature' => @$authResponseBody['Signature'], |
| 1405 | + 'key' => @$authResponseBody['ObjectKey'], |
| 1406 | + 'file' => $fileObj, |
| 1407 | + 'success_action_status' => '201', |
| 1408 | + ]; |
| 1409 | + $this->_postOSSObject(@$authResponseBody['Bucket'], $ossHeader); |
| 1410 | + $deepfakeDetectIntlStreamReq->faceFile = 'http://' . @$authResponseBody['Bucket'] . '.' . @$authResponseBody['Endpoint'] . '/' . @$authResponseBody['ObjectKey'] . ''; |
| 1411 | + } |
| 1412 | + |
| 1413 | + return $this->deepfakeDetectIntlStreamWithOptions($deepfakeDetectIntlStreamReq, $runtime); |
| 1414 | + } |
| 1415 | + |
1240 | 1416 | /** |
1241 | 1417 | * Delete Face Group. |
1242 | 1418 | * |
|
0 commit comments