WeChat public account custom menu PHP version

小云云
Release: 2023-03-20 22:50:01
Original
4946 people have browsed it

本文主要和大家分享微信公众号自定义菜单PHP版,希望能帮助到大家。


        
Copy after login
//7200 var_dump($jsoninfo);
Copy after login
$access_token = $jsoninfo["access_token"]; //d定义菜单的格式 $jsonmenu = '{ "button":[ { "name":"看科普", "sub_button":[ { "type":"view", "name":"专家讲堂", "url":"http://m.hao123.com/a/tianqi" }, { "type":"view", "name":"不孕不育", "url":"http://m.hao123.com/a/tianqi" }, { "type":"view", "name":"试管婴儿", "url":"http://m.hao123.com/a/tianqi" }] }, { "name":"问医生", "sub_button":[ { "type":"view", "name":"入口", "url":"http://m.hao123.com/a/tianqi" } ] }, { "name":"找服务", "sub_button":[ { "type":"view", "name":"商城入口", "url":"http://m.hao123.com/a/tianqi" }, { "type":"view", "name":"海外就医", "url":"http://m.hao123.com/a/tianqi" }, { "type":"view", "name":"名院推荐", "url":"http://m.hao123.com/a/tianqi" }] } ] }'; $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".$access_token; $result = https_request($url, $jsonmenu);
Copy after login
var_dump($result); function https_request($url,$data = null){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); if (!empty($data)){ curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); curl_close($curl); return $output; } ?>
Copy after login
array(2) { ["access_token"]=> string(156) "5_wfmiTe_SkJX6ZyY4jIvg6AyJJuaMh2qnxAtRSrxvRkmGOQXpgihlkHXNb4Ah6aTrJVodeA_oEONcr1oOb0ALYyW7UHIBUqcvg2p0H-6KSabXNbNYxHerLbf49Z-Pac_Z7gp2P-PQaey-GR_zMPCdADAWZM" ["expires_in"]=> int(7200) } string(27) "{"errcode":0,"errmsg":"ok"}" 生成的连个数组,我是按照文档一步步来的 写的比较粗糙,可以直接运行
Copy after login

相关推荐:

PHP创建微信自定义菜单的方法

实现微信公众号企业号中自定义菜单接口的php代码

有关公众平台自定义菜单的文章推荐10篇

The above is the detailed content of WeChat public account custom menu PHP version. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!