用sae 做服务器,制作微信菜单【 完整源码】
<?php
$access_token = " 这个位置填写你的token,它有720秒的存在时间" ;
$jsonmenu='{
"button": [
{
"name": "微荣网络",
"sub_button": [
{
"type": "view", // 类型为连接
"name": "微官网",
"url": "http://m.wsq.qq.com/app?sId=263458415&appId=wsq512e1714179fd6" // 连接地址
},
{
"type": "view",
"name": "创业市场",
"url": "http://www.haiduky.org"
},
{
"type": "view",
"name": "上门维修",
"url": "http://mp.weixin.qq.com/s?__biz=MzAwOTA5NDc0NA==&mid=201519499&idx=1&sn=e3eb0f59571360420c22ae350fe11c02#rd"
},
{
"type": "view",
"name": "网站建设",
"url": "http://mp.weixin.qq.com/s?__biz=MzAwOTA5NDc0NA==&mid=201521770&idx=1&sn=463c9fcb5657ea43aa8441326b187ddb#rd"
},
{
"type": "view",
"name": "微信营销",
"url": "http://mp.weixin.qq.com/s?__biz=MzAwOTA5NDc0NA==&mid=201521429&idx=1&sn=70f3280ae355e70f3969f59030197582#rd"
}
]
},
{
"name": "网络安全",
"sub_button": [
{
"type": "view",
"name": "网安常识",
"url": "http://mp.weixin.qq.com/s?__biz=MzAwOTA5NDc0NA==&mid=201520158&idx=1&sn=eb8d86ed94560377e70a5a3eb67082a1#rd"
},
{
"type": "view",
"name": "防黑技术",
"url": "http://mp.weixin.qq.com/s?__biz=MzAwOTA5NDc0NA==&mid=201520801&idx=1&sn=79ded78d3d965073761b2694556ab640#rd"
},
{
"type": "view",
"name": "网安培训",
"url": "http://mp.weixin.qq.com/s?__biz=MzAwOTA5NDc0NA==&mid=201518798&idx=1&sn=cfd3be76716b606523b4d9b021b4faba#rd"
},
{
"type": "view",
"name": "网站培训",
"url": "http://mp.weixin.qq.com/s?__biz=MzAwOTA5NDc0NA==&mid=201519157&idx=1&sn=8f7f17e41350e494e9e68d9d1f997b33#rd"
},
{
"type": "view",
"name": "微营销培训",
"url": "http://mp.weixin.qq.com/s?__biz=MzAwOTA5NDc0NA==&mid=201518708&idx=1&sn=2305317f81a1a434afd7d4c83f7891d7#rd"
}
]
},
{
"name": "联系我们",
"sub_button": [
{
"type": "view",
"name": "进入微社区",
"url": "http://m.wsq.qq.com/263458415"
},
{
"type": "scancode_waitmsg",
"name": "发送您的二维码",
"key": "fser",
"sub_button": [ ] // 不可以省略
},
{
"type": "pic_photo_or_album",
"name": "拍照或相册发图",
"key": "paizhao",
"sub_button": [ ]
},
{
"type": "location_select",
"name": "发送地理位置",
"key": "dili"
},
{
"type": "view",
"name": "联系方式",
"url": "http://mp.weixin.qq.com/s?__biz=MzAwOTA5NDc0NA==&mid=201498427&idx=1&sn=a633764b2078202f5d058fed27f05b26#rd"
}
]
}
]
}';
$url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".$access_token;
$result = https_request($url, $jsonmenu);
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;
}
?>
使用说明:现在微信平台调试接口下,调试好,然后 把这段代码传到自己应用空间,然后在地址栏里运行下。微信公众平台就出现你想要的菜单了。