|
- <?php
- header('Content-Type:text/html; charset=utf-8');
- date_default_timezone_set('PRC');
- include('/usr/share/nginx/XMWX/wechat/Common/Mysql.php');
- $pdo =conn();
- $sql = "SELECT * FROM `wechat_user`";
- $result = $pdo->query($sql);
- $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
- foreach ($rowset as $key => $value) {
- $token =getAccesstoken();
- $result = http_request('https://api.weixin.qq.com/cgi-bin/user/info?access_token='.$token.'&openid='.$value['OPENID'].'&lang=zh_CN');
- $res = (array)json_decode($result);
- if(isset($res['subscribe']) && $res['subscribe']==1){
- $sql = "update wechat_user set CITY ='".$res['city']."', is_register =1,NICKNAME ='".$res['nickname']."',SEX =".$res['sex'].",COUNTRY ='".$res['country']."',PROVINCE ='".$res['province']."' where id =".$value['ID'];
- $result = $pdo->query($sql);
- }elseif($value['IS_REGISTER']==1){
- $sql = "update wechat_user set is_register =2 where id =".$value['ID'];
- $result = $pdo->query($sql);
-
- }
- }
-
- die;
|