小程序中如果有会员功能,那么对于会员发布的内容需要进文本内容安全识别,这也是小程序官网的要求,否则审核不予通过。
https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/sec-center/sec-check/msgSecCheck.html
uniapp:
var that=this
uni.login({
provider: 'weixin', //使用微信登录
success: function (loginRes) {
console.log(loginRes.code);
uni.request({
url: that.baseUrl + 'weixin/user/get_access_token',
data: {
code: loginRes.code
},
success: (res) => {
}
});
}
});php端,appid和AppSecret在小程序后台[开发管理]中获取:
public function get_access_token(){
//https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-access-token/getAccessToken.html
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx8f60b6901c0a0002&secret=9a20745172a9be00072efde54e23165b";
$response = file_get_contents($url);
$response=json_decode($response, true);
//获取openid
$code=input('code');
$appid='wxxxx';
$appSecret='xxx';
$url="https://api.weixin.qq.com/sns/jscode2session?appid=".$appid."&secret=".$appSecret."&js_code=".$code."&grant_type=authorization_code";
$res=file_get_contents($url);
$res= json_decode($res, true);
$open_id=$res['openid'];
//halt($res);
//发送post请求
$url = 'https://api.weixin.qq.com/wxa/msg_sec_check?access_token='.$response['access_token'];
$data =$data_array= ['openid' => $open_id, 'content' => '中国','version'=>2,'scene'=>1];
$options = array(
'http' => array(
'header' => 'Content-Type: application/json',
'method' => 'POST',
'content' => json_encode($data),
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$response = json_decode($result, true);
halt($response);