douyin_security

package module
v0.0.0-...-9475769 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 9 Imported by: 0

README

douyin-security

抖音开放平台内容安全检测包括文本、图片

Install

go get github.com/xiaoxuan6/douyin-security

Usage

// 创建账号
account := douyin_security.NewAccount("xxx", "xxx", true) // app_id, app_secret, 是否为沙箱环境
client := douyin_security.NewClient(account)

// 获取access_token,有效期为2小时,自行缓存,如何不设置每次请求都会获取
accessToken, err := client.GetAccessToken()
client.SetAccessToken(accessToken)

// 设置最大请求次数,默认为3次
client.SetMaxAttempts(3)

// 文本检测
response := client.TextVerify("测试文本")

// 图片检测
response := client.ImageVerify("http://xxxxx.jpg")
or
response := client.ImageVerify("file_base64")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	AppId     string `json:"app_id"`
	AppSecret string `json:"app_secret"`
	IsSandbox bool   `json:"is_sandbox"`
}

func NewAccount

func NewAccount(appid, appSecret string, isSandbox bool) *Account

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(account *Account) *Client

func (*Client) GetAccessToken

func (c *Client) GetAccessToken() (string, error)

func (*Client) ImgVerify

func (c *Client) ImgVerify(image string) *Response

ImgVerify image 支持图片链接或者图片 base64

func (*Client) SetAccessToken

func (c *Client) SetAccessToken(accessToken string)

func (*Client) SetMaxAttempts

func (c *Client) SetMaxAttempts(maxAttempts uint)

func (*Client) TextVerify

func (c *Client) TextVerify(text string) *Response

type Response

type Response struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

func Fail

func Fail(code int, msg string) *Response

func Success

func Success() *Response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL