tp6+图片审核+oss上传

本文介绍了如何在ThinkPHP6(TP6)框架中结合使用图片审核服务和对象存储服务(OSS)进行文件上传。通过CURL发起请求调用百度云的API进行图片审核,提供了一万次免费接口试用。详细步骤和实践方法可供开发者参考。
摘要由CSDN通过智能技术生成

 审核加上传oss

 /**
     * 图片审核
     */
    public function imageAudit()
    {


        $file = request()->file('img');
        $name=$file->getPathname();
        //apikey  这里使用百度云的接口
        $apikey="";
        //SecretKey
        $SecretKey="";
        //获取url
        $url= "https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id={$apikey}&client_secret={$SecretKey}";
        //获取到token;
        $info= curlGet($url);
        $token=$info['access_token'];

        $url = 'https://aip.baidubce.com/rest/2.0/solution/v1/img_censor/v2/user_defined?access_token=' . $token;

        $img = file_get_contents($name);
        $img = base64_encode($img);
        $bodys = array(
            'image' => $img
        );
        $res = json_decode($this->curlPost($url, $bodys),true);
        //根据自己的业务逻辑进行处理
        if
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值