gumo9

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
    }

 

分类:

技术点:

相关文章:

  • 2021-11-30
  • 2019-11-29
  • 2021-10-17
  • 2021-11-01
  • 2021-11-22
  • 2021-12-10
  • 2021-09-26
  • 2021-08-13
猜你喜欢
  • 2021-10-05
  • 2021-11-01
  • 2021-11-08
  • 2022-01-13
  • 2022-01-23
  • 2021-08-17
相关资源
相似解决方案