自定义菜单的创建
<"APPID", "您的appid"); define("APPSECRET", "您的appsecret "); $token_access_url = "https://api.weixin.qq.com/cgi-bin/token" . APPID . "&secret=" . APPSECRET; $res = file_get_contents($token_access_url); //获取文件内容或获取网络请求的内容 //echo $res; $result = json_decode($res, true); //接受一个 JSON 格式的字符串并且把它转换为 PHP 变量 $access_token = $result['access_token']; define("ACCESS_TOKEN", $access_token); //将access_token定义为常量,便于使用. $make_menu_url = "https://api.weixin.qq.com/cgi-bin/menu/create" . ACCESS_TOKEN; $menuData = ' { "button":[ { "type":"click", "name":"今日歌曲", "key":"V1001_TODAY_MUSIC" }, { "name":"菜单", "sub_button":[ { "type":"view", "name":"搜索", "url":"http://www.soso.com/" }, { "type":"view", "name":"视频", "url":"http://v.qq.com/" }, { "type":"click", "name":"赞一下我们", "key":"V1001_GOOD" }] }] }'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $make_menu_url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_AUTOREFERER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $menuData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $info = curl_exec($ch); //判读执行过程中是否有错误,有则发送数据错误报告. if (curl_errno($ch)) { echo 'Error' . curl_error($ch); //用户检查php运行环境中的curl模块开启情况. } curl_close($ch); print_r($info); //查看post提交到微信服务器后,返回的数据.
自定义菜单的获取
<"APPID", "您的appid"); define("APPSECRET", "您的appsecret "); $token_access_url = "https://api.weixin.qq.com/cgi-bin/token" . APPID . "&secret=" . APPSECRET; $res = file_get_contents($token_access_url); //获取文件内容或获取网络请求的内容 $result = json_decode($res, true); //接受一个 JSON 格式的字符串并且把它转换为 PHP 变量 $access_token = $result['access_token']; $make_menu_url = "https://api.weixin.qq.com/cgi-bin/menu/get" . $access_token; $menu_json = file_get_contents($make_menu_url); echo $menu_json;
自定义菜单的删除
<"APPID", "您的appid"); define("APPSECRET", "您的appsecret "); $token_access_url = "https://api.weixin.qq.com/cgi-bin/token" . APPID . "&secret=" . APPSECRET; $res = file_get_contents($token_access_url); //获取文件内容或获取网络请求的内容 $result = json_decode($res, true); //接受一个 JSON 格式的字符串并且把它转换为 PHP 变量 $access_token = $result['access_token']; $make_menu_url = "https://api.weixin.qq.com/cgi-bin/menu/delete" . $access_token; $menu_json = file_get_contents($make_menu_url); echo $menu_json;
以上所述就是本文的全部内容了,希望对大家做微信开发有所帮助。
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年09月23日
2024年09月23日
- 华少翌.2005-华少翌【中唱艺能】【WAV+CUE】
- 群星《十二女声Ⅱ》[WAV/CUE/分轨][527MB]
- 大自然音乐系列《漫步在山裡》[WAV/CUE/分轨][502.8MB]
- 大自然音乐系列《星光夜语》[WAV/CUE/分轨][453.3MB]
- 史依弘《史依弘交响乐京剧演唱专辑HQ》头版限量编号[WAV+CUE]
- 曼丽2020《女人三十风继续吹》HQCD[WAV+CUE]
- 曼丽2021《女人三十2雾之恋》HQCD[WAV+CUE]
- 隔壁老樊.2019-我曾【好听音乐】【FLAC分轨】
- 高林生.1993-牵挂你的人是我【白天鹅】【WAV+CUE】
- 洪卓立.2012-找个懂我的女孩(国专)【英皇娱乐】【WAV+CUE】
- 曼丽2022《女人三十3晚秋》HQCD[WAV+CUE]
- 曼丽2018《女人三十4冬天》HQCD[WAV+CUE]
- 柏菲-《好歌30年壹》限量开盘母带ORMCD[低速原抓WAV+CUE]
- 大自然音乐系列《水舞》[WAV/CUE/分轨][424.3MB]
- 大自然音乐系列《星光夜语》[WAV/CUE/分轨][453.3MB]