使用PHP SDK查询异步检测结果。

接口描述

ImageAsyncScanResultsRequest
功能 支持的Region 描述
查询异步检测结果 cn-shanghaicn-beijing 在调用ImageAsyncScanRequest进行异步图片检测(接口会对每一张图片分配一个taskId)后使用,通过taskId获取异步图片检测的结果。

调用示例

关于调用请求中的检测场景参数 scene,返回结果中的分类参数 label,以及操作建议参数 suggestion的说明,请参考SDK 调用参数说明
<?php
include_once 'aliyuncs/aliyun-php-sdk-core/Config.php';
use Green\Request\V20180509 as Green;
date_default_timezone_set("PRC");
$ak = parse_ini_file("aliyun.ak.ini");
// 请替换成您自己的accessKeyId、accessKeySecret
$iClientProfile = DefaultProfile::getProfile("cn-shanghai", $ak["accessKeyId"], $ak["accessKeySecret"]); // TODO
DefaultProfile::addEndpoint("cn-shanghai", "cn-shanghai", "Green", "green.cn-shanghai.aliyuncs.com");
$client = new DefaultAcsClient($iClientProfile);
$request = new Green\ImageAsyncScanResultsRequest();
$request->setMethod("POST");
$request->setAcceptFormat("JSON");
$request->setContent(json_encode(array("e9754e32-1df5-4a29-b28d-d7249196d27f-1492740069185")));
try {
    $response = $client->getAcsResponse($request);
    print_r($response);
    if(200 == $response->code){
        $taskResults = $response->data;
        foreach ($taskResults as $taskResult) {
            if(200 == $taskResult->code){
                $sceneResults = $taskResult->results;
                foreach ($sceneResults as $sceneResult) {
                    $scene = $sceneResult->scene;
                    $suggestion = $sceneResult->suggestion;
                    //根据scene和suggetion做相关处理
                    //do something
                    print_r($scene);
                    print_r($suggestion);
                }
            }else{
                print_r("task process fail:" + $response->code);
            }
        }
    }else{
        print_r("detect not success. code:" + $response->code);
    }
} catch (Exception $e) {
    print_r($e);
}