阿里PHP SDK有错误,需要提交工单下载最新版绿网SDK。
include_once '../aliyun-php-sdk-core/Config.php';
$iClientProfile = DefaultProfile::getProfile("cn-beijing", "****", "****");
$client = new DefaultAcsClient($iClientProfile);
$imgarr = array('http://car3.autoimg.cn/cardfs/product/g23/M12/79/11/t_autohomecar__wKjBwFbLs9eALF9AAAUuaxzPFtU837.jpg','http://car2.autoimg.cn/cardfs/product/g18/M06/C4/B2/t_autohomecar__wKjBxVYxakmASWLRAAl9AbYaVUI095.jpg');
checkImage($imgarr);
function checkImage($array){
global $client;
$ckrequest = new Green\Request\V20151209\ImageDetectionRequest();
$ckrequest->putDomainParameters("async", true);
$ckrequest->putDomainParameters("image_url", $array);
$ckrequest->putDomainParameters("scene", array("porn"));
$response = $client->getAcsResponse($ckrequest);
$response = json_decode($response);
if($response->code == 'Success'){
$task_arr = array();
foreach ($response->images as $value) {
array_push($task_arr, $value->task_id);
}
ResultRequest($task_arr);
}else{
echo '调用错误';
}
}
// 图片检测结果
function ResultRequest($tid){
global $client;
$request = array();
foreach ($tid as $value) {
$barequest = new Green\Request\V20151209\ImageResultRequest();
$barequest -> setUriPattern("/image/result/". $value);
while (true) {
$baresponse = $client->getAcsResponse($barequest);
if(strpos($baresponse, '"porn":{"label"') !== false){
array_push($request, json_decode($baresponse));
break;
}
}
}
print_r($request);
}
发表评论
沙发空缺中,还不快抢~