标签:com php DDM day add case ati 网址 ret
<?php namespace App\Http\Controllers; class WeChatController extends Controller{ //用户列表 public function userList() { $app = app(‘wechat.official_account.default‘); return $app->user->list(); } //获取菜单 public function getMenu(){ $app = app(‘wechat.official_account.default‘); return $app->menu->list(); } //创建临时二维码 public function createQrcode(){ $app = app(‘wechat.official_account.default‘); $result = $app->qrcode->temporary(‘foo‘, 6 * 24 * 3600);//创建 return $result; } //获取二维码网址 public function getUrl(){ $app = app(‘wechat.official_account.default‘); $url = $app->qrcode->url(‘gQGX7zwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyQjhwRFpMN2RmckMxTm9TeXhzYzUAAgRYTdpcAwQA6QcA‘); echo $url; } //删除全部菜单 public function delMenu(){ $app = app(‘wechat.official_account.default‘); $res = $app->menu->delete(); // 全部 return $res; } //添加菜单 public function addMenu(){ $app = app(‘wechat.official_account.default‘); $buttons = [ [ "type" => "click", "name" => "今日歌曲", "key" => "V1001_TODAY_MUSIC" ], [ "name" => "菜单", "sub_button" => [ [ "type" => "view", "name" => "搜索", "url" => "http://www.soso.com/" ], [ "type" => "view", "name" => "视频", "url" => "http://v.qq.com/" ], [ "type" => "click", "name" => "赞一下我们", "key" => "V1001_GOOD" ], ], ], ]; $res = $app->menu->create($buttons); return $res; } //消息 public function server(){ $app = $app = app(‘wechat.official_account.default‘); $app->server->push(function ($message) use ($app){ // $user = $app->user->get($message[‘FromUserName‘]); // return ‘你好‘.$user[‘nickname‘].‘;您刚刚说了一句:‘.$message[‘Content‘]; switch ($message[‘MsgType‘]) { case ‘event‘: return ‘收到事件消息‘; break; case ‘text‘: return ‘收到文字消息‘; break; case ‘image‘: return ‘收到图片消息‘; break; case ‘voice‘: return ‘收到语音消息‘; break; case ‘video‘: return ‘收到视频消息‘; break; case ‘location‘: return ‘收到坐标消息‘; break; case ‘link‘: return ‘收到链接消息‘; break; case ‘file‘: return ‘收到文件消息‘; // ... 其它消息 default: return ‘收到其它消息‘; break; } }); $response = $app->server->serve(); return $response; } }
标签:com php DDM day add case ati 网址 ret
原文地址:https://www.cnblogs.com/jiangshiguo/p/10861951.html