// 测试公众号
//1
$appid = 'wx5465521d7b9461ab';
//2
//$appid = 'wxefb8b736c3c052a2';
//1
$secret = 'c8e7c33e7ae138f37a4024bdfd69eb11';
//2
//$secret = 'f216bdff4410803fed4360bcaa8541e9';
$accesstoken = file_get_contents("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}");
$token=json_decode($accesstoken,true);
$sub_button[] = array('type'=>'view','name'=>urlencode('海参鉴别'),'url'=>'http://shengongguan.xun-ao.com');
$sub_button[] = array('type'=>'view','name'=>urlencode('专业发海参'),'url'=>'http://shengongguan.xun-ao.com/index.php/Home/Index/trepang_soak');
$sub_button[] = array('type'=>'view','name'=>urlencode('参公馆厨房'),'url'=>'http://shengongguan.xun-ao.com/index.php/Home/Index/trepang_cuisine');
$sub_button[] = array('type'=>'view','name'=>urlencode('食用小贴士'),'url'=>'http://shengongguan.xun-ao.com/index.php/Home/Index/trepang_taboo');
$sub_button[] = array('type'=>'view','name'=>urlencode('养生大课堂'),'url'=>'http://shengongguan.xun-ao.com/index.php/Home/Index/attend_class');
$button[] = array('name'=>urlencode('海参讲堂'),'sub_button'=>$sub_button);
unset($sub_button);
$sub_button[] = array('type'=>'view','name'=>urlencode('海参下午茶'),'url'=>'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx5465521d7b9461ab&redirect_uri=http://shengongguan.xun-ao.com/index.php/Home/User/index/type/1&response_type=code&scope=snsapi_base&state=a124#wechat_redirect');
$sub_button[] = array('type'=>'view','name'=>urlencode('食参客分享'),'url'=>'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx5465521d7b9461ab&redirect_uri=http://shengongguan.xun-ao.com/index.php/Home/User/Diners_share/type/1&response_type=code&scope=snsapi_base&state=a124#wechat_redirect');
$sub_button[] = array('type'=>'view','name'=>urlencode('评价你的顾问'),'url'=>'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx5465521d7b9461ab&redirect_uri=http://shengongguan.xun-ao.com/index.php/Home/User/consultant_Evaluation/type/1&response_type=code&scope=snsapi_base&state=a124#wechat_redirect');
$sub_button[] = array('type'=>'view','name'=>urlencode('参观原产地'),'url'=>'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx5465521d7b9461ab&redirect_uri=http://shengongguan.xun-ao.com/index.php/Home/User/visit/type/1&response_type=code&scope=snsapi_base&state=a124#wechat_redirect');
$sub_button[] = array('type'=>'view','name'=>urlencode('积分兑换'),'url'=>'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx5465521d7b9461ab&redirect_uri=http://shengongguan.xun-ao.com/index.php/Home/Cart/new_integral/type/1&response_type=code&scope=snsapi_base&state=a124#wechat_redirect');
$button[] = array('name'=>urlencode('食参客'),'sub_button'=>$sub_button);
unset($sub_button);
$button[] = array('type'=>'view','name'=>urlencode('我是会员'),'url'=>'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx5465521d7b9461ab&redirect_uri=http://shengongguan.xun-ao.com/index.php/Home/Member/index/type/1&response_type=code&scope=snsapi_base&state=a124#wechat_redirect');
unset($sub_button);
$data['button'] = $button;
$data = urldecode(json_encode($data));
echo post("https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".$token["access_token"],$data);
function post($url, $jsonData){
$ch = curl_init($url) ;
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS,$jsonData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($ch) ;
curl_close($ch) ;
var_dump($result);
return $result;
}
一键复制
编辑
Web IDE
原始数据
按行查看
历史