Exemplo n.º 1
0
 public function chatHandle($openid)
 {
     $User = new \Weixin\Event\UserEvent();
     $res = $User->sendMessage(I('get.openid'), I('post.chat_content'));
     if ($res['errcode'] == 0) {
         $this->jsonReturn(1, '发送成功' . $res['errmsg']);
     } else {
         $this->jsonReturn(0, '发送失败' . $res['errmsg']);
     }
 }
Exemplo n.º 2
0
 public function sendHandle($msgid = 0)
 {
     @set_time_limit(0);
     if (I('post.openid') != 'all') {
         $User = new \Weixin\Event\UserEvent();
         $res = $User->sendMessage(I('post.openid'), I('post.content'));
         if ($res['errcode'] == 0) {
             $this->success('发送成功');
         } else {
             $this->error('发送失败' . $res['errmsg']);
         }
     } else {
         $User = new \Weixin\Event\UserEvent();
         $Users = D('Weixinuser');
         $user_list = $Users->relation(true)->select();
         $info = '';
         $now = (int) current_timestamp();
         foreach ($user_list as $value) {
             $time_remain = $now - (int) $value['log'][0]['CreateTime'] - 60 * 60 * 24 * 2;
             if ($value['log'][0]['CreateTime'] != null && $time_remain < 0) {
                 $res = $User->sendMessage($value['openid'], I('post.content'));
                 $info .= $value['openid'] . $res['errmsg'];
             }
         }
         $this->success('发送成功:' . $info);
     }
 }