TP5 百度智能云 内容审核 SDK 调用

PHP SDK 官方下载地址

PHP SDK 官方文档

我把 PHP SDK 放到了TP5的 extend  了

在这里我根据 PHP SDK 再次封装了一下函数,代码示下

复制代码
    /**
     * 百度云内容审核
     * @param  [type] $type    内容类型 image msg
     * @param  [type] $content 内容
     * @return [type]          [description]
     */
    public function checkRes($type,$content)
    {
        include  'extend/bdapi/AipContentCensor.php';
        $AppID = '21****46';
        $APIKey = 'dAX***************hLv';
        $SecretKey = 's5sl*******************8v90';
        $client = new \AipContentCensor($AppID, $APIKey, $SecretKey);
        if($type == 'image'){
            $isUrl = substr(trim($content), 0, 4) === 'http';
            if(!$isUrl){
                $content = file_get_contents($content);
            }
            $result = $client->imageCensorUserDefined($content);
        }else{
            $result = $client->textCensorUserDefined($content);
        }
        if (isset($result['conclusion']) && $result['conclusion'] == '合规') {
            $data = [
                'status'=>'success',
                'code'=>1,
                'msg'=>'合规'
            ];
        } else {
            $data = [
                'status'=>'error',
                'code'=>0,
                'msg'=>'不合规'
            ];
        }
        return $data
    }
复制代码

 

posted @   孤陌  阅读(403)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示