All Products
Search
Document Center

ImageAsyncScanResultsRequest

Last Updated: Jun 06, 2019

Interface description

An interface used to obtain the asynchronous image moderation results

SDK interface

  1. ImageAsyncScanResultsRequest

region

  1. ap-southeast-1

Depended interface

ImageAsyncScanResultsRequest is applied after ImageAsyncScanRequest is used to perform asynchronous image moderation (the interface assigns a taskId to every image), and obtains asynchronous image moderation results based on the taskIds.

Sample code

  1. <?php
  2. include_once 'aliyuncs/aliyun-php-sdk-core/Config.php';
  3. use Green\Request\V20170112 as Green;
  4. date_default_timezone_set("PRC");
  5. $ak = parse_ini_file("aliyun.ak.ini");
  6. //Replace with your accessKeyId and accessKeySecret
  7. $iClientProfile = DefaultProfile::getProfile("ap-southeast-1", $ak["accessKeyId"], $ak["accessKeySecret"]); // TODO
  8. DefaultProfile::addEndpoint("ap-southeast-1", "ap-southeast-1", "Green", "green.ap-southeast-1.aliyuncs.com");
  9. $client = new DefaultAcsClient($iClientProfile);
  10. $request = new Green\ImageAsyncScanResultsRequest();
  11. $request->setMethod("POST");
  12. $request->setAcceptFormat("JSON");
  13. $request->setContent(json_encode(array("e9754e32-1df5-4a29-b28d-d7249196d27f-1492740069185")));
  14. try {
  15. $response = $client->getAcsResponse($request);
  16. print_r($response);
  17. if(200 == $response->code){
  18. $taskResults = $response->data;
  19. foreach ($taskResults as $taskResult) {
  20. if(200 == $taskResult->code){
  21. $sceneResults = $taskResult->results;
  22. foreach ($sceneResults as $sceneResult) {
  23. $scene = $sceneResult->scene;
  24. $suggestion = $sceneResult->suggestion;
  25. //Take actions according to scene and suggestion in returned results
  26. //do something
  27. print_r($scene);
  28. print_r($suggestion);
  29. }
  30. }else{
  31. print_r("task process fail:" + $response->code);
  32. }
  33. }
  34. }else{
  35. print_r("detect not success. code:" + $response->code);
  36. }
  37. } catch (Exception $e) {
  38. print_r($e);
  39. }