# 菜單事件
用戶點擊自定義菜單后,微信會把點擊事件推送給開發者,點擊一級菜單彈出子菜單,不會產生上報。
[TOC]
### 點擊菜單拉取消息時的事件推送
```
//消息管理模塊
$instance = WeChat::instance('button');
//關注用戶掃描二維碼事件
if ($instance->isClickEvent()) {
//獲取消息內容
$message = $instance->getMessage();
//向用戶回復消息
return WeChat::instance('message')->text("點擊了菜單,EventKey: {$message->EventKey}");
}
```
### 點擊菜單跳轉鏈接時的事件推送
```
//消息管理模塊
$instance = WeChat::instance('button');
//關注用戶掃描二維碼事件
if ($instance->isViewEvent()) {
//獲取消息內容
$message = $instance->getMessage();
file_put_contents('hd.php',$message->EventKey);
}
```
### 掃碼推事件的事件推送
```
//消息管理模塊
$instance = WeChat::instance('button');
if ($instance->isScancodePush()){
//處理的代碼
}
```
### 掃碼推事件且彈出“消息接收中”提示框的事件推送
```
//消息管理模塊
$instance = WeChat::instance('button');
if ($instance->isScancodeWaitmsg()){
//處理的代碼
}
```
### 彈出系統拍照發圖的事件推送
```
//消息管理模塊
$instance = WeChat::instance('button');
if ($instance->isPicSysphoto()){
//處理的代碼
}
```
### 彈出拍照或者相冊發圖的事件推送
```
//消息管理模塊
$instance = WeChat::instance('button');
if ($instance->isPicPhotoOrAlbum()){
//處理的代碼
}
```
### 彈出微信相冊發圖器的事件推送
```
//消息管理模塊
$instance = WeChat::instance('button');
if ($instance->isPicWeixin()){
//處理的代碼
}
```
### 彈出地理位置選擇器的事件推送
```
//消息管理模塊
$instance = WeChat::instance('button');
if ($instance->isLocationSelect()){
//處理的代碼
}
```