tp5 微信小程序 图片鉴黄

function imgcheck($path) {
//path是本地图片路径
    $url = "https://api.weixin.qq.com/wxa/img_sec_check?access_token=" . AccessToken();
    $file_data = array("media" => new \CURLFile($path));
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $file_data);
    $output = curl_exec($ch); //发送请求获取结果
    curl_close($ch); //关闭会话
    return $output;
}

AccessToken请看https://mp.csdn.net/mdeditor/82885296#
返回值为ok图片就没有问题

你可能感兴趣的:(微信小程序,thinkphp)