var express = require('express'); var tuxiang = express(); let fs = require('fs'); var AipImageCensorClient = require("baidu-aip-sdk").imageCensor; // 设置APPID/AK/SK var APP_ID = "18186918"; var API_KEY = "oSkFVuYN25fpsezEVklVqRQf"; var SECRET_KEY = "GnEyZlIIpY0Y1hgbIAR8UDKNtA4z6h73"; var client = new AipImageCensorClient(APP_ID, API_KEY, SECRET_KEY);
官方文档没有更新 ,我自己查看的源码,你这么写就行了
谁来帮帮我啊。。。谢谢
代码如下:
var express = require('express');
var tuxiang = express();
let fs = require('fs');
var AipImageCensorClient = require("baidu-aip-sdk").imageCensor;
// 设置APPID/AK/SK
var APP_ID = "18186918";
var API_KEY = "oSkFVuYN25fpsezEVklVqRQf";
var SECRET_KEY = "GnEyZlIIpY0Y1hgbIAR8UDKNtA4z6h73";
var client = new AipImageCensorClient(APP_ID, API_KEY, SECRET_KEY);
var HttpClient = require("baidu-aip-sdk").HttpClient;
HttpClient.setRequestOptions({timeout: 5000});
HttpClient.setRequestInterceptor(function(requestOptions) {
// 查看参数
console.log(requestOptions)
// 修改参数
requestOptions.timeout = 5000;
// 返回参数
return requestOptions;
});
client.imageCensorUserDefined(base64Img, 'base64').then(function(data) {
console.log(': ' + JSON.stringify(data));
}, function(e) {
console.log(e)
});
tuxiang.listen(4000);
tuxiang.get('/', function (req, res) {
res.send('开始')
})