<?php
|
include_once '/Common/CommFunc.php';
|
include_once '/Common/Logging.php';
|
include_once "/Common/Commtox7.php";
|
|
// https://api.x7sy.com/api_helper/x7DetectionAccess
|
|
header("Content-type: text/html; charset=utf-8");
|
|
\Logging\CreateLogging("center.x7.messageDetect.php");
|
|
$channel = $_POST["channel"];
|
$guid = $_POST["guid"];
|
$detectionMessage = $_POST["detectionMessage"];
|
$operateType = $_POST["operateType"];
|
$osType = $_POST["osType"];
|
|
if (!$channel || !$guid || !$detectionMessage || !$operateType) {
|
DefaultFail("paramerror");
|
exit;
|
}
|
if (!$osType) {
|
$osType = "android";
|
}
|
|
\Logging\LogInfo("_POST:" . print_r($_POST, true));
|
|
if (
|
!\CommFunc\GetConfig("x7", "messageDetectUrl", $messageDetectUrl) ||
|
!\CommFunc\GetConfig("x7", "Appkey_" . $osType . "_" . $channel, $appkey) ||
|
!\CommFunc\GetConfig("x7", "Pubkey_" . $osType . "_" . $channel, $pubkey) ||
|
!\CommFunc\GetConfig("sign", "Prikey_" . $channel, $prikey)
|
) {
|
DefaultFail("configerror");
|
exit;
|
}
|
|
// bizParams字段 类型 必选 说明
|
// guid String 是 角色所属小号ID
|
// detectionMessage String 是 需要检测的信息
|
|
$apiMethod = "x7Detection.messageDetect";
|
$bizParams = array(
|
"guid" => $guid,
|
"detectionMessage" => $detectionMessage,
|
);
|
|
send_common_to_x7($messageDetectUrl, $bizParams, $appkey, $prikey, $pubkey, $apiMethod, "messageDetectRespone", "client", $osType);
|
|
exit;
|
|
function messageDetectRespone($response, $appkey, $prikey, $pubkey)
|
{
|
// bizResp字段 类型 必选 说明
|
// respCode String 是 响应码,SUCCESS代表成功
|
// respMsg String 是 响应提示信息
|
// detectResult Array 否 道具信息数组
|
//
|
// detectResult 字段 类型 必选 说明
|
// detectionLogId String 是 检查结果的ID
|
// level String 是 检查结果的分类级别【1:通过,-1:不通过】
|
// labelCode String 是 违规分类码【0:正常; 1:其他; 2:色情; 3:广告; 4:暴恐; 5:违禁; 6:涉政; 7:谩骂; 8:灌水; 9:违反广告法; 10:涉价值观】
|
// sensitiveWords Array 是 敏感词数组
|
global $messageDetectUrl, $operateType;
|
|
\Logging\LogInfo("response:" . print_r($response, true));
|
$bizResp = $response["bizResp"];
|
|
echo $bizResp;
|
|
$ret = json_decode($bizResp, true);
|
// 不通过时,汇报处理结果
|
if ($ret["respCode"] == "SUCCESS" && array_key_exists("detectResult", $ret) && $ret["detectResult"]["level"] == -1) {
|
// 请求bizParams
|
// bizParams 字段 类型 必选 说明
|
// detectionLogId String 是 检查结果的ID
|
// operateType String 是 对检测结果的处理类型【1:拦截发送(禁止该消息发送并提示发送文本中含有敏感信息); 2:不展示(允许发送但实际上会拦截不展示); 3、屏蔽关键词(屏蔽敏感词后剩余内容允许发送); 4、其他】
|
//
|
// 响应bizResp
|
// bizResp 字段 类型 必选 说明
|
// respCode String 是 响应码,SUCCESS代表成功
|
// respMsg String 是 响应提示信息
|
$detectionLogId = $ret["detectResult"]["detectionLogId"];
|
$apiMethod = "x7Detection.messageDetectReport";
|
$bizParams = array(
|
"detectionLogId" => $detectionLogId,
|
"operateType" => $operateType,
|
);
|
send_common_to_x7($messageDetectUrl, $bizParams, $appkey, $prikey, $pubkey, $apiMethod);
|
}
|
}
|
|
function DefaultFail($respMsg)
|
{
|
echo json_encode(array("respCode" => "FAIL", "respMsg" => $respMsg));
|
}
|