爱程序网

微信公众平台自定义菜单

来源: 阅读:

最近微信公众平台挺火的,肯定好多公司像我们公司一样,要开发微信公众平台,在此记录一下在制作 自定义菜单时遇到的问题,

希望能给某些人点思路,或少走点弯路.

为了动态修改自定义菜单,把菜单项存入数据库中 $arr是从数据库查询出来的经过处理后的数组格式为:

array(1) {  ["button"] => array(3) {    [0] => array(3) {      ["type"] => string(4) "view"      ["name"] => string(12) "公司新闻"      ["url"] => string(24) "http://www.google.com.tw"    }    [1] => array(3) {      ["type"] => string(4) "view"      ["name"] => string(12) "公司案例"      ["url"] => string(20) "http://www.baidu.com"    }    [2] => array(2) {      ["name"] => string(12) "智能家居"      ["sub_button"] => array(5) {        [0] => array(3) {          ["type"] => string(5) "click"          ["name"] => string(12) "功能描述"          ["key"] => string(10) "smart_desc"        }        [1] => array(3) {          ["type"] => string(5) "click"          ["name"] => string(12) "每日一点"          ["key"] => string(9) "day_click"        }        [2] => array(3) {          ["type"] => string(5) "click"          ["name"] => string(12) "一天一点"          ["key"] => string(13) "eve_day_click"        }        [3] => array(3) {          ["type"] => string(5) "click"          ["name"] => string(12) "休闲时刻"          ["key"] => string(11) "xiuxian_day"        }        [4] => array(3) {          ["type"] => string(5) "click"          ["name"] => string(12) "做人好难"          ["key"] => string(3) "nan"        }      }    }  }}