Now, many of the activities to guide users to pay attention to the public, in order to participate in activities, then how to judge the user concerned about the public number? This article will provide you with PHP code to solve the problem.
Official Interface Description
Get basic user information (including Unionid mechanism)
Http://mp.weixin.qq.com/wiki/14/bb5031008f1494a59c6f71fa0f319c66.html
1, as long as the basic access_token and user OpenID can determine whether the user is concerned about the public number
2, the interface URL to use: https://api.weixin.qq.com/cgi-bin/user/info?access_token= $token &openid= $openid 3, Determines whether the field returned by the interface subscribe is 1. "1 followers, 0 not paying attention"
Note:
1, the method of judging the user login is silent authorization, the user does not perceive, thereby obtaining the user's OpenID;
2, judge the user login, need to support the certification service number, subscription number does not work;
Here is the 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 ' not paying attention! ';} Private Function _getaccesstoken () {$where = array (' token ' = > $this-> Token); $this-> Thiswxuser = M (' Wxuse R ')-> 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: Error code '. $json-> Errcode. ', return error message: '. $jso N-> ErrMsg); } return $json-> Access_token;}? >
The above is the whole content of this article, I hope that everyone's learning has helped.
The above describes the public number development public number to determine whether the user has been concerned about PHP code parsing, including the development of the public number of content, I hope that the PHP tutorial interested in a friend helpful.