Beispiel #1
0
 /**
  * 当用户第一次关注公众号的时候,进行数据库插入操作
  * @param referer  0 为搜索关注,1 为二维码关注
  * @param type  二维码类型,1 为临时二维码,2为永久
  */
 public function weixin_subscribe($openid, $referer = 0, $sell_id = 0)
 {
     $sqlUser = new sql_userMod();
     $res = $sqlUser->get_user_openid($openid);
     if ($res) {
         $sqlUser->set_user_subscribe($res['p_id'], $res['sub_time'] + 1);
     } else {
         $r = connectRedis($this->config['RD_HOST'], $this->config['RD_PORT'], $this->config['RD_DB']);
         $token = $r->get('token');
         $wx_res = Weixin::get_user_info($token, $openid);
         if ($wx_res) {
             $res = $sqlUser->add_user_subscribe($wx_res, $referer, str_replace('sell_id', '', $sell_id));
             dump($res);
         }
     }
 }