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

提供两个鉴黄接口 #166

Open
gincoder opened this issue Jul 25, 2024 · 0 comments
Open

提供两个鉴黄接口 #166

gincoder opened this issue Jul 25, 2024 · 0 comments

Comments

@gincoder
Copy link

图片鉴黄和图片内容审核

<script>
// =================================================接口1===========================================
function fetchGetRequest(url) {
  return fetch(url)
    .then(response => {
      if (!response.ok) {
        throw new Error('Network response was not ok');
      }
      return response.json(); // 解析 JSON 数据
    })
    .then(data => {
	  //console.log(data);
	  console.log(data.result.rating_index);
	  // 结果:1 所有人,2 青少年 ,3 为不良图片
      return data; // 返回解析后的数据
    })
    .catch(error => {
      console.error('There has been a problem with your fetch operation:', error);
      throw error; // 抛出错误,可根据需要处理
    });
}
//const apiUrl = 'https://api.oioweb.cn/api/ai/jianhuang?url=https://cn.bing.com/th?id=OHR.ArizonaPinkMoon_ZH-CN5545607389_1920x1080.jpg';
//fetchGetRequest(apiUrl)
// =================================================接口2===========================================
function fetchPostRequest(url, data) {
  return fetch(url, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json', // 根据实际情况设置 Content-Type
    },
    body: JSON.stringify(data), // 将 JavaScript 对象转换为 JSON 字符串
  })
  .then(response => {
    if (!response.ok) {
      throw new Error('Network response was not ok');
    }
    return response.json(); // 解析 JSON 数据
  })
  .then(data => {
    return data; // 返回解析后的数据
  })
  .catch(error => {
    console.error('There has been a problem with your fetch operation:', error);
    throw error; // 抛出错误,可根据需要处理
  });
}
const apiUrl = 'https://tools.mgtv100.com/external/v1/qcloud_content_audit';
const postData = { 
				audit_content: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', 
				audit_type: 'image' 
			};

fetchPostRequest(apiUrl, postData)
  .then(data => {
    console.log('POST 请求成功:', data.data.Lable);
    // 结果: 
  })
  .catch(error => {
    // 处理请求失败的情况
    console.error('请求失败:', error);
  });
</script>
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

1 participant