<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>项目列表</title>
    <?

php PrintPageHead(); ?> <link href="resource/css/hermes.css" rel="stylesheet"> <link href="resource/js/calendar/calendar-blue.css" type="text/css" rel="stylesheet"> <script src="resource/js/calendar/calendar.js" type="text/javascript"></script> <script src="resource/js/hermes.js"></script> <style type="text/css"> .divleft{width: 13%; float: left; text-align:left; border-right: solid 1px #d5d5d5; margin-right: 2% } .divleft2{width: 9%; float: left; text-align:left; border-right: solid 1px #d5d5d5; margin-right: 2% } .divright{ width: 12%; float:right; text-align: right;} </style> <?php if (!array_key_exists("公众号ID",$_SESSION)) { header("Location:back.php"); } if(isset($_POST['id'])){ $用户信息=pdo()->selectColumns("用户",array('name'),array("id"=>$_POST['id'])); $name=$用户信息['name']; $公众号accToken =fh通过公众号id获取公众号Token信息($_SESSION['公众号ID']); $url2="https://api.weixin.qq.com/cgi-bin/groups/get?access_token=".$公众号accToken; $ret2=json_decode(file_get_contents($url2)); $查找=$ret2->groups; $是否加入=1; $分组id=''; foreach($查找 as $key => $value){ if($value->name==$用户信息['name']){ $是否加入=0; $分组id=$value->id; break; } } if($是否加入){ $url="https://api.weixin.qq.com/cgi-bin/groups/create?access_token=".$公众号accToken; $cont='{"group":{"name":"'.$name.'"}}'; $ret = Tools::curl_post_page改($url,$cont); $返回=json_decode($ret); $分组id=$返回->group->id; } if($分组id){ $是否成功=0; $do= new Do新会员卡(); $会员信息=pdo()->selectBOs($do,array("商户id"=>$_POST['id'])); foreach($会员信息 as $key => $value){ $url移动="https://api.weixin.qq.com/cgi-bin/groups/members/update?access_token=".$公众号accToken; $cont移动='{"openid":"'.$value->data['会员oid'].'","to_groupid":'.$分组id.'}'; $rety = Tools::curl_post_page改($url移动,$cont移动); if($rety)$是否成功++; } if($是否成功){echo "<script>alert('移动成功');</script>";} } } ?> </head> <body> <div class="container-fluid"> <div class="panel panel-primary"> <div class="panel-heading text-center"><h3 class="panel-title">公众号分组</h3></div> <div> <form action="" method="post"> 用户id<input type="text" name="id"> <input type="submit" value="加入分组" name="oks"> </form> </div> </div> </div> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="resource/js/jquery-1.11.1.min.js"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="resource/js/bootstrap.min.js"></script> </body> </html> <?

php

 function fh通过公众号id获取公众号Token信息($公众号id) {
//        $pdo = pdo();
//        /** @var  $公众号 DoPublic_serv_accounts */
//        $Do參数 = new DoUniversalparameters();
//        $公众号參数 = $pdo -> selectColumns('UniversalParameters',array('value'),array('公众号id'=>$公众号id,'name'=>'AccessToken'));
//        return $公众号參数['value'];
       $公众号openID = pdo()->selectColumns('public_serv_accounts',array('公众号openID'),array('id'=>$公众号id));
        return self::getAccessToken($公众号id,$公众号openID['公众号openID']);
    }





?

>