# 創建菜單
[toc]
> 以下代碼是創建普通菜單,但創建掃碼推事件、彈出系統拍照發圖等菜單只需要構造相應數據即可。
**請求示例**
```php
$button = '{
"button": [
{
"type": "click",
"name": "今日歌曲",
"key": "V1001_TODAY_MUSIC"
},
{
"name": "菜單",
"sub_button": [
{
"type": "view",
"name": "搜索",
"url": "http://www.soso.com/"
},
{
"type": "click",
"name": "贊一下我們",
"key": "V1001_GOOD"
}
]
}
]
}';
WeChat::instance('button')->create($button);
```
或者
```php
$button = array (
'button' =>
array (
0 =>
array (
'type' => 'click',
'name' => '今日歌曲',
'key' => 'V1001_TODAY_MUSIC',
),
1 =>
array (
'name' => '菜單',
'sub_button' =>
array (
0 =>
array (
'type' => 'view',
'name' => '搜索',
'url' => 'http://www.soso.com/',
),
1 =>
array (
'type' => 'click',
'name' => '贊一下我們',
'key' => 'V1001_GOOD',
),
),
),
),
);
WeChat::instance('button')->create($button);
```
**返回值**
正確時的返回如下
```
array(2) {
["errcode"] => int(0)
["errmsg"] => string(2) "ok"
}
```