微信用json_encode来创建自定义菜单为为什么会失败

浏览:1585 发布日期:2015/03/17 分类:求助交流 关键字: 微信 Thinkphp 自定义菜单
        $data['button'][0]['name']='菜单一';
        $data['button'][1]['name']='菜单二';
        $data['button'][2]['name']='菜单三';


        $data['button'][0]['sub_button'][0]['name']='跳转菜单';
        $data['button'][0]['sub_button'][0]['type']='view';
        $data['button'][0]['sub_button'][0]['url']='http://www.baidu.com';
        $data['button'][0]['sub_button'][0]['sub_button']=array();     

        $data['button'][0]['sub_button'][1]['name']='点击菜单';
        $data['button'][0]['sub_button'][1]['type']='click';
        $data['button'][0]['sub_button'][1]['key']='xyz_key_1';
        $data['button'][0]['sub_button'][1]['sub_button']=array();     

        $data['button'][0]['sub_button'][2]['name']='扫码事件';
        $data['button'][0]['sub_button'][2]['type']='scancode_push';
        $data['button'][0]['sub_button'][2]['key']='xyz_key_2';
        $data['button'][0]['sub_button'][2]['sub_button']=array();

        $data['button'][0]['sub_button'][3]['name']='扫码提示';
        $data['button'][0]['sub_button'][3]['type']='scancode_waitmsg';
        $data['button'][0]['sub_button'][3]['key']='xyz_key_3';
        $data['button'][0]['sub_button'][3]['sub_button']=array();



        $data['button'][0]['sub_button'][4]['name']='微信相册';
        $data['button'][0]['sub_button'][4]['type']='pic_weixin';
        $data['button'][0]['sub_button'][4]['key']='xyz_key_6';
        $data['button'][0]['sub_button'][4]['sub_button']=array();




        $data['button'][1]['sub_button'][0]['name']='选择地理位置事件';
        $data['button'][1]['sub_button'][0]['type']='location_select';
        $data['button'][1]['sub_button'][0]['key']='xyz_key_7';
        $data['button'][1]['sub_button'][0]['sub_button']=array();

        $data['button'][1]['sub_button'][1]['name']='拍照发图';
        $data['button'][1]['sub_button'][1]['type']='pic_sysphoto';
        $data['button'][1]['sub_button'][1]['key']='xyz_key_4';  
        $data['button'][1]['sub_button'][1]['sub_button']=array();     

        $data['button'][1]['sub_button'][2]['name']='拍照相册';
        $data['button'][1]['sub_button'][2]['type']='pic_photo_or_album';
        $data['button'][1]['sub_button'][2]['key']='xyz_key_5'; 
        $data['button'][1]['sub_button'][2]['sub_button']=array();     

        $data['button'][1]['sub_button'][3]['name']='跳转菜单4';
        $data['button'][1]['sub_button'][3]['type']='view';
        $data['button'][1]['sub_button'][3]['url']='http://www.baidu.com';
        $data['button'][1]['sub_button'][3]['sub_button']=array();     

        $data['button'][1]['sub_button'][4]['name']='跳转菜单6';
        $data['button'][1]['sub_button'][4]['type']='view';
        $data['button'][1]['sub_button'][4]['url']='http://www.baidu.com';
        $data['button'][1]['sub_button'][4]['sub_button']=array();     



        $data['button'][2]['sub_button'][0]['name']='选择地理位置事件';
        $data['button'][2]['sub_button'][0]['type']='location_select';
        $data['button'][2]['sub_button'][0]['key']='xyz_key_7';

        $data['button'][2]['sub_button'][1]['name']='跳转菜单7';
        $data['button'][2]['sub_button'][1]['type']='view';
        $data['button'][2]['sub_button'][1]['url']='http://www.baidu.com';
        $data['button'][2]['sub_button'][1]['sub_button']=array();     

        $data['button'][2]['sub_button'][2]['name']='跳转菜单8';
        $data['button'][2]['sub_button'][2]['type']='view';
        $data['button'][2]['sub_button'][2]['url']='http://www.baidu.com';
        $data['button'][2]['sub_button'][2]['sub_button']=array();     

        $data['button'][2]['sub_button'][3]['name']='跳转菜单9';
        $data['button'][2]['sub_button'][3]['type']='view';
        $data['button'][2]['sub_button'][3]['url']='http://www.baidu.com';
        $data['button'][2]['sub_button'][3]['sub_button']=array();     

        $data['button'][2]['sub_button'][4]['name']='跳转菜单10';
        $data['button'][2]['sub_button'][4]['type']='view';
        $data['button'][2]['sub_button'][4]['url']='http://www.baidu.com';
        $data['button'][2]['sub_button'][4]['sub_button']=array();     
        $json=json_encode($data);
我通过这样生成微信自定义菜单为什么会返回{"errcode":40016,"errmsg":"invalid button size"}

而我在微信的官方调试工具上把上面生成的json填进去就能创建成果。
最佳答案
评论( 相关
后面还有条评论,点击查看>>