微信api 群发 图文消息

header('Content-type: text/html; charset=utf-8');#设置头信息
require_once('zhphpWeixinApi.class.php');
$zhwx=new zhphpWeixinApi();//实例化
$configArr=array(
     'token'=>'weixintest',
     'appid'=>'wx7b4b6ad5c7bfaae1',
     'appSecret'=>'faaa6a1e840fa40527934a293fabfbd1',
     'myweixinId'=>'gh_746ed5c6a58b'
     );
 $zhwx->setConfig($configArr);##配置参数
 $zhwx->checkAccessToken();##检查token
 $userlist=$zhwx->getUserList();##获取用户列表
 
 //var_dump($userlist);
 //$callData=$zhwx->mediaUpload('image','a.jpg');## 上传图片到微信  得到 media id
//CQKrXGNiJWiKutD17CWhoqlqW_80IByyFpLWa-dnPzhl7jPpQFiBbXhsAQVwId-q
  $data=array(
        array(
            "thumb_media_id"=>"CQKrXGNiJWiKutD17CWhoqlqW_80IByyFpLWa-dnPzhl7jPpQFiBbXhsAQVwId-q",
            "author"=>"xxx",
            "title"=>"Happy Day",
            "content_source_url"=>"www.qq.com",
            "content"=>"
文章内容
",
            "diges"=>"digest"
        ),
);
 //$aa=$zhwx->newsUpload($data);//上传图文素材[ media_id] => 2n32OjOIdP7jewG0d55bKvuJYcH6XpWTeg8ViHCfzHGgKBZxmE72s3T2LY-3Q8LO





if(isset($_POST['sub'])){
   $touser=$_POST['userOpenId'];
    //开始群发
     $content='
    

    
这是商品说明

     ';
     $content.='查看详情: 国家统计局局长王保安涉嫌严重违纪被免职';
   // $data= $zhwx->sendMassMessage('text',$touser,$content);
     $data=$zhwx->sendMassMessage('news',$touser,'2n32OjOIdP7jewG0d55bKvuJYcH6XpWTeg8ViHCfzHGgKBZxmE72s3T2LY-3Q8LO'); ##主动发送图文消息
    echo '
'; 
  
   print_r($data);
    echo '
';
    exit;
}
if(isset($userlist['errcode']) && $userlist['errcode']== '45009'){
      echo  '对不起,这是测试接口,今日已经超过调用限制。请明日再来';
  }else{
     ?>
    


    微信群发信息
    



           $userinfos=array();
       foreach($userlist['data'] as  $key=>$user){
            foreach($user as $kk=>$list){
                $userinfos[]=$zhwx->getUserInfo($list);
            }
        }
     ?>
    

        

            

请选择用户


            
                
                    
                    
                    
                    
                    
                    
                    
                    
                
                                  foreach($userinfos  as $key=>$userinfo){
                     ?>
                    
                        
                        
                        
                        
                        
                        
                        
                        
                    
                                  }
                 ?>
            
编号 关注事件类型 用户姓名 性别 头像 所在地 所在组 操作
                             if($userinfo['subscribe'] == 1){
                                 echo '普通关注事件';
                             }
                             ?>
                               if(empty($userinfo['headimgurl'])){
                                 echo '没有头像';
                             }else{
                                 echo '';
                             }
                             ?>
                             if($userinfo['groupid']  == 0){
                                 echo '没有分组';
                             }else{
                                 echo '还有完善功能';
                             }
                             ?>
                        

             
        

   



  }
?>








你可能感兴趣的:(开发应用,php)