在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
微信官方文档 https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Creating_Custom-Defined_Menu.html php代码 // 自定义菜单 public function menu(){ // 实例化微信操作类 $wx = new Wechat(); $token = $wx->getAccessToken(); $jsonmenu = '{ "button":[ { "name":"天气预报", "sub_button":[ { "type":"click", "name":"北京天气", "key":"天气北京" }, { "type":"click", "name":"上海天气", "key":"天气上海" }, { "type":"click", "name":"广州天气", "key":"天气广州" }, { "type":"click", "name":"深圳天气", "key":"天气深圳" }, { "type":"view", "name":"本地天气", "url":"http://m.hao123.com/a/tianqi" }] }, { "name":"瑞雪", "sub_button":[ { "type":"click", "name":"公司简介", "key":"company" }, { "type":"click", "name":"趣味游戏", "key":"游戏" }, { "type":"click", "name":"讲个笑话", "key":"笑话" }] }] }'; $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=$token"; // 生成自定义菜单 $res = $wx->http_curl($url, 'post', 'json', $jsonmenu); echo "<pre>"; print_r($res); } 效果图
Wechat类是我自己封装的,比如获取access_token,ticket,curl请求这些,代码可以看上一篇文字 微信开发之生成二维码,扫码关注公众号PHP 思路说明: 1.公众号配置:JS安全域名,IP白名单 2.获取AccessToken,过期时间默认为7200秒 3.生成菜单:携带AccessToken和自定义菜单内容,并调用生成菜单接口(需注意拼接菜单格式) |
2022-07-18
2022-08-30
2022-08-17
2022-11-06
2022-08-17
请发表评论