微信红包开发分享统计模块

<?php
require_once("../includes/conn.php");
require_once("../includes/wxtoken.php");
$tools=new tools();
if(!$tools->check_is_weixin()){
    header("Location:guanzhu.php");
    exit;
}
$sysconfig=$dbconn->fetch($dbconn->query("select * from ".DBQIAN."sys_config order by id desc limit 1"));
$hongbaorow=$dbconn->fetch($dbconn->query("select * from ".DBQIAN."xianjin_set order by id desc limit 1"));
define('APPID', $sysconfig['cappid']);
define('APPSECRET', $sysconfig['cappsecret']);

$wxtoken = new wxtoken();
$signPackage = $wxtoken->GetSignPackage();

$utcode = ( isset($_GET['utcode']) && $_GET['utcode']!='' ) ? $_GET['utcode']:'';
//获取用户的openid
if(isset($_GET['code']) && $_GET['code']!=''){
   $WXCODE=$_GET['code'];
   $getucodeurl="https://api.weixin.qq.com/sns/oauth2/access_token?appid=".APPID."&secret=".APPSECRET."&code=".$WXCODE."&grant_type=authorization_code";
   $getucodejson=json_decode($tools->http_curl_get($getucodeurl,true));
   $ucode=$getucodejson->openid;//自己的ucode

   if($ucode==''){
      header("Location:index.php?utcode=".$utcode);
      exit;
   }

   $usernum=$dbconn->countn(DBQIAN."user_list"," ucode='$ucode' ");
   $access_token=$wxtoken->getAccessToken();
   $geturl="https://api.weixin.qq.com/cgi-bin/user/info?access_token=".$access_token."&openid=".$ucode."&lang=zh_CN";
   $getutxtjson =json_decode($tools->http_curl_get($geturl,true));
   if($getutxtjson->subscribe==1){
      $uickname    =iconv("UTF-8","GBK",$getutxtjson->nickname);
      $usex        =intval($getutxtjson->sex);
      $headimgurl  =$getutxtjson->headimgurl;
      $udizhi      =iconv("UTF-8","GBK",$getutxtjson->province).iconv("UTF-8","GBK",$getutxtjson->city);    
      $utime=time();
      if($usernum == 0){
           $dbconn->noretquery("insert into ".DBQIAN."user_list(ucode,utcode,uickname,usex,uheadimgurl,udizhi,utime)values
                  ('$ucode','$utcode','$uickname',$usex,'$headimgurl','$udizhi',$utime)");
      }
   } else {
       $utime=time();
       if($usernum == 0){
          $dbconn->noretquery("insert into ".DBQIAN."user_list(ucode,utcode,utime)values('$ucode','$utcode',$utime)");
       }
   }
}

?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
<title>Duang!一大波钱正在来袭!</title>
<link rel="stylesheet" href="../css/index.css" />
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
  wx.config({   
    debug: false,
    appId: '<?php echo $signPackage["appId"];?>',
    timestamp: <?php echo $signPackage["timestamp"];?>,
    nonceStr: '<?php echo $signPackage["nonceStr"];?>',
    signature: '<?php echo $signPackage["signature"];?>',
    jsApiList: [
        'checkJsApi',
        'onMenuShareTimeline',
        'onMenuShareAppMessage',
        'onMenuShareQQ',
        'onMenuShareWeibo',
        'hideMenuItems',
        'showMenuItems',
        'hideAllNonBaseMenuItem',
        'showAllNonBaseMenuItem',
        'translateVoice',
        'startRecord',
        'stopRecord',
        'onRecordEnd',
        'playVoice',
        'pauseVoice',
        'stopVoice',
        'uploadVoice',
        'downloadVoice',
        'chooseImage',
        'previewImage',
        'uploadImage',
        'downloadImage',
        'getNetworkType',
        'openLocation',
        'getLocation',
        'hideOptionMenu',
        'showOptionMenu',
        'closeWindow',
        'scanQRCode',
        'chooseWXPay',
        'openProductSpecificView',
        'addCard',
        'chooseCard',
        'openCard'
    ]
  });
wx.ready(function () {
    wx.hideOptionMenu();
    wx.onMenuShareTimeline({
         title: "<?php echo str_replace("%%%",iconv("GBK","UTF-8",$hongbaorow['uickname']),iconv("GBK","UTF-8",$hongbaorow['kfentitle']));?>",
         link: "<?php echo WEBNAME."main/index.php?utcode=".$ucode;?>",
         imgUrl: "<?php $times=date("Ymd",$hongbaorow['htime']);
         echo WEBNAME."uploads/".substr($times,0,4)."/".substr($times,4,2)."/".$hongbaorow['hfenimg']; ?>",
         trigger: function (res) {
         },
         success: function (res) {       
         },
         cancel: function (res) {            
         },
         fail: function (res) {
         }
    });
    wx.onMenuShareAppMessage({
        title: "<?php echo str_replace("%%%",iconv("GBK","UTF-8",$hongbaorow['uickname']),iconv("GBK","UTF-8",$hongbaorow['kfentitle']));?>",
        desc: "<?php iconv("GBK","UTF-8",$hongbaorow['hfendes']);?>",
        link: "<?php echo WEBNAME."main/index.php?utcode=".$ucode;?>",
        imgUrl: "<?php $times=date("Ymd",$hongbaorow['htime']);
         echo WEBNAME."uploads/".substr($times,0,4)."/".substr($times,4,2)."/".$hongbaorow['hfenimg']; ?>",
        trigger: function (res) {
        },
        success: function (res) {
        },
        cancel: function (res) {
        },
        fail: function (res) {
        }
     });
     wx.error(function(res){
         alert('监测到您的页面加载有异常,请刷新后重试');
         location.href="index.php?utcode=<?php echo $utcode;?>";
     });
});
</script>
</head>

<body>
<?php
$userrow=$dbconn->fetch($dbconn->query("select * from ".DBQIAN."user_list where ucode='$utcode'"));
?>

<img src="../images/back.png" width="100%" /> <img class="avatar" src="<?php echo substr($userrow['uheadimgurl'],0,-1).'132';?>" width="60" height="60"/>
<p class="nickname"><?php echo iconv("GBK","UTF-8",$userrow['uickname']);?>的礼物</p>
<a href="guanzhu.php"  style="text-decoration: none;"><button class="btn-give">我也要</button></a>
<div class="already-get">看看都有谁在抢...</div>

<div class="content">
  <ul>
    <?php
    $sql="select ".DBQIAN."user_xianjin.utxt,".DBQIAN."user_xianjin.utime,".DBQIAN."user_list.uheadimgurl,".DBQIAN."user_list.uickname from ".DBQIAN."user_xianjin left join ".DBQIAN."user_list on ".DBQIAN."user_xianjin.ucode=".DBQIAN."user_list.ucode where ".DBQIAN."user_xianjin.xtype=1 and ".DBQIAN."user_list.uheadimgurl<>'' order by ".DBQIAN."user_xianjin.id desc limit 0,25";
    $query=$dbconn->query($sql);
    while($row=$dbconn->fetch($query)){
    ?>
    <li> <img class="receiver_avatar" width="36" height="36" src="<?php echo substr($row['uheadimgurl'],0,-1).'132';?>" />
      <div class="receiver_info">
        <div style="margin-bottom: 2px;"> <span class="nickname"><?php echo iconv("GBK","UTF-8",$row['uickname']);?></span> <span class="time"><?php echo date("m/d H:i:s",$row['utime']);?></span> </div>
        <div class="desc"><?php echo $row['utxt'];?></div>
      </div>
      <div class="receiver_flow"> 
        <!--<div class="red">0.10元</div>--> 
      </div>
    </li>
    <?php } ?>
  </ul>
</div>
</body>
</html>

**以上是我做的公共平台微信红包系统的部分代码,将来我会给大家讲一下这个系统的整体原理,然后开源吧-.-。
require_once(“../includes/conn.php”); //链接数据库的- -
require_once(“../includes/wxtoken.php”); //确定微信身份的=.=
别的地方不会的话,留言问我吧= =引用一个笑话。
夏天,某农村生产队,男妇女主任身穿背心、大裤衩,正在向台下的妇女同志发表讲话,兴致勃勃,讲到兴起,抬腿将脚踏一板凳上,继续口若悬河,不巧,裤衩裆部开口过大,台下妇女看到了裤衩里面的*头,妇女们很兴奋,纷纷热烈鼓掌,连声叫好,妇女主任以为自己演讲水平极高,很是得意,说:”这只是个头,后面还长着呢“。话毕,掌声如雷。

**

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值