Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weapp v3版本文本检测好像用的还是腾讯的v1的接口? #78

Open
fukcup opened this issue May 16, 2022 · 7 comments
Open

weapp v3版本文本检测好像用的还是腾讯的v1的接口? #78

fukcup opened this issue May 16, 2022 · 7 comments

Comments

@fukcup
Copy link

fukcup commented May 16, 2022

Q:调用v3版本的MSGSecCheck,貌似有些内容检测不出来;
腾讯文本检测API v2介绍页:
https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.msgSecCheck.html

@royalrick
Copy link
Owner

    sdk := weapp.NewClient("your-appid", "your-secret")
    cli := sdk.NewSecurity()

是这样调用的吗?

@fukcup
Copy link
Author

fukcup commented May 18, 2022

使用的方法不一样; 我调用的 wechat.WeChatClient.MSGSecCheck(content) 这个方法。 我的wechat.WeChatClient相当于你的那个sdk

@fukcup
Copy link
Author

fukcup commented May 18, 2022

我试试你说的这个方法

@fukcup
Copy link
Author

fukcup commented May 18, 2022

这个方法可以使用,谢谢

@fukcup
Copy link
Author

fukcup commented May 18, 2022

    sdk := weapp.NewClient("your-appid", "your-secret")
    cli := sdk.NewSecurity()

是这样调用的吗?

可以检测到非法内容,但是返回的错是一个json反序列化的错.而不是腾讯返回的错误类型。查看源码应该是Label这个字段 一个是string,一个是int.官方返回的是string.

type MsgSecCheckResponse struct {
	request.CommonError
	// 唯一请求标识,标记单次请求
	TraceId string `json:"trace_id"`
	// 综合结果
	Result struct {
		// 建议,有risky、pass、review三种值
		Suggest string `json:"suggest"`
		// 命中标签枚举值,100 正常;10001 广告;20001 时政;20002 色情;20003 辱骂;20006 违法犯罪;20008 欺诈;20012 低俗;20013 版权;21000 其他
		Label string `json:"label"`
	} `json:"result"`
	// 详细检测结果
	Detail []struct {
		// 策略类型
		Strategy string `json:"strategy"`
		// 错误码,仅当该值为0时,该项结果有效
		Errcode int `json:"errcode"`
		// 建议,有risky、pass、review三种值
		Suggest string `json:"suggest"`
		// 命中标签枚举值,100 正常;10001 广告;20001 时政;20002 色情;20003 辱骂;20006 违法犯罪;20008 欺诈;20012 低俗;20013 版权;21000 其他
		Label int `json:"label"`
		// 0-100,代表置信度,越高代表越有可能属于当前返回的标签(label)
		Prob int `json:"prob"`
		// 命中的自定义关键词
		Keyword string `json:"keyword"`
	} `json:"detail"`
}

@fukcup
Copy link
Author

fukcup commented May 18, 2022

@royalrick
Copy link
Owner

OK了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants