/*
* 自定义菜单
*/
public function action_createOrdinaryMenu(){
//菜单字符串
$menujson = '{
"button": [
{
"type": "media_id",
"name": "游戏下载",
"media_id": "_zYCUGjI0M4vsn3IToupRuMAdwWeAjbkiTrOSTNYAMo"
}
]
}';
$url = $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".$this->get_access_token();
//创建菜单
$result = Utils::https_request($url, $menujson);
//返回{"errcode":0,"errmsg":"ok"}表示成功
echo $result;
}
/**
* 安卓个性化菜单
*/
public function action_androidWxMenu(){
//菜单字符串
$menujson = '{
"button": [
{
"type": "media_id",
"name": "游戏下载",
"media_id": "_zYCUGjI0M4vsn3IToupRuMAdwWeAjbkiTrOSTNYAMo"
},
{
"type": "view",
"name": "充值优惠",
"url": "http://mapi.shen021.com/mobile/wechat"
}
],
"matchrule":{
"client_platform_type": "2"
}
}';
$url = $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".Utils::get_access_token();
//创建菜单
$result = Utils::https_request($url, $menujson);
//返回{"errcode":0,"errmsg":"ok"}表示成功
echo $result;
}
/**
* IOS个性化菜单
*/
public function action_iosWxMenu(){
$menujson = '{
"button":[
{
"type": "click",
"name": "游戏下载",
"key": "game down",
"url":"https://apps.apple.com/cn/app/%E7%94%B3%E5%9F%8E%E6%96%97%E5%9C%B0%E4%B8%BB/id1521970769"
}
],
"matchrule":{
"client_platform_type": "1"
}
}';
$url = "https://api.weixin.qq.com/cgi-bin/menu/addconditional?access_token=".Utils::get_access_token();
//创建个性化菜单
$result = Utils::https_request($url, $menujson);
//返回返回menuid表示成功
echo $result;
}
/**
* 删除菜单
*/
public function action_deleteMenu(){
$url = "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=".Utils::get_access_token();
//删除菜单
$result = Utils::https_request($url);
echo $result;
}
/**
* 获取菜单
*/
public function action_getMenu(){
p(Utils::get_access_token());
$url = "https://api.weixin.qq.com/cgi-bin/get_current_selfmenu_info?access_token=".Utils::get_access_token();
$result = Utils::https_request($url);
p($result);
}
/**
* 测试菜单
*/
public function action_testMenu(){
$url = "https://api.weixin.qq.com/cgi-bin/menu/trymatch?access_token=".Utils::get_access_token();
$result = Utils::https_request($url,'{"user_id":"shencheng123-456"}');
p($result);
}