使用接口创建自定义菜单后,开发者还可使用接口删除当前使用的自定义菜单。
删除菜单的接口如下:
https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=ACCESS_TOKEN
删除自定义菜单代码实现如下所示:
$url = "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=".$access_token; $result = https_request($url); 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; }
正确时的返回JSON数据包如下:
{"errcode":0,"errmsg":"ok"}