The recent voting campaign to do a micro-trust platform needs to be focused on public numbers before voting, so how can you tell if the user is concerned about the public number?
The first idea was to get a public-number attention list and then search the list for the participants ' OpenID.
But the immediate problem is that this approach requires a list of concerns every time, and when the public number of fans is relatively long, this approach is more strenuous.
Use the PHP method below to determine whether the user is concerned about the public number:
<?php
$access _token = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid= Xxxxxxxxxxxxxxxxxx&secret=xxxxxxxxxxxxxxxxxxxxxxxxxx ";
$access _msg = Json_decode (file_get_contents ($access _token));
$token = $access _msg->access_token;
$subscribe _msg = "https://api.weixin.qq.com/cgi-bin/user/info?access_token= $token &openid=$_get[openid]";
$subscribe = Json_decode (file_get_contents ($subscribe _msg));
$gzxx = $subscribe->subscribe;
if ($gzxx = = 1) {
echo "attention";
} else{
echo "not concerned";
}
Here is the second code case
< php $access _token = $this-> _getaccesstoken (); $subscribe _msg = ' Https://api . weixin.qq.com/cgi-bin/user/info?access_token= '. $access _token. '
&openid= '. $_session[' wecha_id '];
$subscribe = Json_decode ($this-> Curlget ($subscribe _msg));
$zyxx = $subscribe-> subscribe; if ($zyxx!== 1) {echo ' is not concerned!
';
Private Function _getaccesstoken () {$where = array (' token ' = > $this-> Token);
$this-> Thiswxuser = M (' wxuser ')-> where ($where)-> Find (); $url _get = ' https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid= '. $this-> thiswxuser[' AppID ']. '
&secret= '. $this-> thiswxuser[' Appsecret '];
$json = Json_decode ($this-> Curlget ($url _get)); if (! $json-> ErrMsg) {} else {$this-> error (' Get Access_token errors: Error code '. $json-> Errcode. ', micro-letter Returns an error message: '. $jso
N-> ErrMsg);
Return $json-> Access_token; }
? >
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.