# 创建菜单
[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"
}
```