腾讯IM云端审核-主动送审对接
1、接口文档:https://cloud.tencent.com/document/product/269/94300
2、对应调用接口代码(注意,音视频是异步审核,调用前需先获取插入的数据,方便回调代码修改审核状态)
function content_moderation($uid,$type,$content,$action_type=0,$action_id=0)
{
$api = getTxRestApi();
$ret = $api->content_moderation($type, $content);
if ($ret['ActionStatus'] == 'OK') {
if($ret['Result'] == 'Block'){
//记录审核内容
DI()->notorm->live_check_logs->insert([
'uid' => $uid,
'content_type' => $type,
'img' => $content,
'score' => $ret['Score'],
'label' => $ret['Label'],
'suggestion' => $ret['Result'],
'send_time' => time(),
'create_time' => time(),
]);
return 0;
}else if(in_array($type,['Audio','Video'])){
$r = DI()->notorm->live_check_logs->insert([
'uid' => $uid,
'content_type' => $type,
'img' => $content,
'score' => 0,
'label' => '',
'suggestion' => '',
'send_time' => time(),
'create_time' => time(),
'req_id' => $ret['RequestId'],
'action_id' => $action_id,
'action_type' => $action_type
]);
return $ret['RequestId'];
}
return 1;
} else {
return 0;
}
}
3、回调开启,审核结果返回,并且返回方式是所有都返回
4、回调地址配置,回调地址同im回调是同一个,开启后,处理对应回调逻辑
//云端审核
if($data['CallbackCommand']=='ContentCallback.ResultNotify'){
$req\_id = $data['CtxcbRequestId'];
$result = $data['CtxcbSuggestion'];
$log = Db::name('live\_check\_logs')->where('req\_id',$req_id)->find();
if(!$log){
echo json_encode($rs);
exit;
}
$configpri = getConfigPri();
$dynamic\_switch = $configpri['dynamic_switch'];
if($log\['action\_type'\] == 2 && $dynamic_switch == 0){//动态,并且是自动审核
$dynamic = Db::name('dynamics')->find($log['action_id']);
if($dynamic){
if($result == 'Block'){
Db::name('live_check_logs')->where('id',$log['id'])->update(['suggestion' => 'Block']);
Db::name('dynamics')->where('id',$log['action_id'])->update(['status' => 2]);
$this->sendIm($dynamic['uid'],'您的动态违规,审核被拒');
}else{
Db::name('live_check_logs')->where('id',$log['id'])->update(['suggestion' => 'Pass']);
Db::name('dynamics')->where('id',$log['action_id'])->update(['status' => 1]);
$this->sendIm($dynamic['uid'],'您的动态已审核通过');
}
}
}else if($log['action_type'] == 1){
$user = Db::name('user')->find($log['action_id']);
if($user){
if($result == 'Block'){
Db::name('live_check_logs')->where('id',$log['id'])->update(['suggestion' => 'Block']);
Db::name('user')->where('id',$log['action_id'])->update(['audio' => '','audio_length' => 0]);
$this->sendIm($log['action_id'],'您的语音签名违规,已被删除');
}else{
Db::name('live_check_logs')->where('id',$log['id'])->update(['suggestion' => 'Pass']);
Db::name('user')->where('id',$log['action_id'])->update(['audio_status' => 1]);
$this->sendIm($log['action_id'],'您的语音签名已审核通过');
}
}
}
}