收藏
回答

c# 后台调用msgSecCheck,始终suggest: "pass"什么情况?

c# 后台调用msgSecCheck验证文本内容安全,返回值

{strategy: "keyword",errcode: 0,strategy: "keyword",errcode: 0,strategy: "keyword",errcode: 0,

strategy: "content_model",errcode: 0,errcode: 0,errmsg: "ok",trace_id: "63b53f64-539c0acd-132f3c5d",

detail: [{strategy: "content_model",

errcode: 0,strategy: "content_model",errcode: 0,strategy: "keyword",errcode: 0,strategy: "keyword",

errcode: 0,strategy: "content_model",errcode: 0,suggest: "pass",label: 100,prob: 90,},

{strategy: "keyword",errcode: 0,},],

result: {suggest: "pass",label: 100,},}

使用的测试词条如下(官方给的测试用例),始终都是通过,

#代码如下:


byte[] bytes = Encoding.Default.GetBytes(body.content);

string content = Encoding.UTF8.GetString(bytes);

Dictionary<string, object> par = new Dictionary<string, object>

{ { "openid",d.openId},{ "scene",4}, { "version",2}, { "content",content} };



HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

            req.Method = "POST";

            req.ContentType = "application/json; charset=UTF-8";

            StringBuilder builder = new StringBuilder();

            builder.Append(JsonHelper.SerializeJson(par));

            byte[] data = Encoding.UTF8.GetBytes(builder.ToString());

            req.ContentLength = data.Length;

            using (Stream reqStream = req.GetRequestStream())

            {

                reqStream.Write(data, 0, data.Length);

                reqStream.Close();

            }

            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();

            Stream stream = resp.GetResponseStream();

            using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))

            {

                backMsg = reader.ReadToEnd();

            }


奇怪的很

回答关注问题邀请回答
收藏

1 个回答

  • Mr.Zhao
    Mr.Zhao
    2023-01-04

    没看见词条在哪

    2023-01-04
    有用
    回复 10
    • Serein
      Serein
      2023-01-04
      https://developers.weixin.qq.com/miniprogram/dev/framework/security.msgSecCheck-v1.html
      过滤掉了,用的是链接中的测试用例
      2023-01-04
      回复
    • Mr.Zhao
      Mr.Zhao
      2023-01-04回复Serein
      这是version1的用例  不是version2
      2023-01-04
      回复
    • Serein
      Serein
      2023-01-04
      2023-01-04
      回复
    • Serein
      Serein
      2023-01-04
      但是我用图片中的还是返回pass,是不是我代码问题呢?
      2023-01-04
      回复
    • Serein
      Serein
      2023-01-04
      2023-01-04
      回复
    查看更多(5)
登录 后发表内容