<?php

namespace web\api;

class thirdapi {
    static function checkbadmedia_wx($url, $rsuser, $media_type) {
        $post = array();
        $post['media_url'] = $url;
        $post['media_type'] = $media_type;//1:音频;2:图片
        $post['version'] = 2;
        $post['scene'] = 4;
        $post['openid'] = $rsuser['wxminaid'];
        $weixinapi = new \web\api\weixin(1);
        //https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/sec-center/sec-check/mediaCheckAsync.html
        $wxret = $weixinapi->call('https://api.weixin.qq.com/wxa/media_check_async?access_token={accesstoken}', $post);
        if (is_string($wxret))
            return errjson($wxret);
        $json['code'] = 1;
        if ($wxret['result']['suggest'] == 'pass')
            return true;
        $wxret['user'] = $rsuser;
        savelogfile('wx_badword', json_encode($wxret));
        return '违规，不能发布';
    }
    static function checkbadword_wx($content, $rsuser) {
        $post = array();
        $post['content'] = $content;
        $post['version'] = 2;
        $post['scene'] = 4;
        $post['openid'] = $rsuser['wxminaid'];
        $weixinapi = new \web\api\weixin(1);
        //https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/sec-center/sec-check/msgSecCheck.html
        $wxret = $weixinapi->call('https://api.weixin.qq.com/wxa/msg_sec_check?access_token={accesstoken}', $post);
        if (is_string($wxret))
            return errjson($wxret);
        $json['code'] = 1;
        if ($wxret['result']['suggest'] == 'pass')
            return true;
        $wxret['user'] = $rsuser;
        savelogfile('wx_badword', json_encode($wxret));
        return '有违禁词，不能发布';
    }
    static function checkbadword_luckycola($wordstr, $strict = 1) {
        return true;
        $http = new \ciy\http();
        $post = array();
        $post['ColaKey'] = 'V0txKKBrP8xzyN1761587699258qq6ro7N0sC'; //2025-12-27 1:54:59   https://luckycola.com.cn/public/dist/#/userCenter
        $post['wordStr'] = $wordstr;
        $post['isStrict'] = $strict;
        $http->request('https://luckycola.com.cn/tools/sensiWords', json_encode($post));
        $result = $http->get_data();
        $json = json_decode($result, true);
        if ($json === null)
            return '内容分析请求失败';
        if ($json['code'] != 0)
            return $json['msg'];
        if($json['isPass'] == true)
            return true;
        savelogfile('bakword', $result);
        return '有违禁词，不能发布';
//{"code":-99,"msg":"colaKey无效","data":{}}
//{"code":0,"msg":"检测成功","isPass":true,"data":{"words":[],"text":"asdfsadf"}}
//{"code":0,"msg":"检测成功","isPass":false,"data":{"words":["法轮","法轮大法"],"text":"法轮大法好啊啊阿萨德"}}
    }
}
