<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv= "Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
// Replace with your own AppID and AppSecret
$appId = 'wxd95fca43ae595a61';
$appSecret = '872a95a04a7e1bd78e3f01020ac195f1 ';
// Get Access Token
$url = "https://api.weixin.qq.com/cgi-bin/token? grant_type=client_credential&appid={$appId}&secret={$appSecret}";
$response = file_get_contents($url);
$result = json_decode($response, true);
$accessToken = $result['access_token'];
// Create the JSON structure of the bottom menu bar
$menu = array(
'button' => array(
'sub_button' => ; array(
array(
having ’ ’s having ’s having ’s out out out out out out out out out Out out out out of it , and . ' url' => 'https://www.example.com/submenu1',
),
array(
'type' => 'click' ,
'name' = & gt ;'faa,
'Url' = & gt; # to 'Sub_button' = & GT; Array (
## Array ( 'Type' = & GT;# 'url' = & gt; 'https://www.example.com/subsenu1',
##), Array (' Type '= > 'click', 'name' => 'FANUC','url' => 'https://www.example.com/submenu1',
array ( 'name' = & gt; 'fail query', 'Sub_button' = & GT 'type' => 'view', 'name' => 'Yaskawa', 'url' => 'https://www.example.com/submenu1 ', array( ’ ', ' url '= & gt;' https://www.example.com/submenu1',
##),
##), ), ),);// Convert menu structure to JSON string and URL encode
$data = json_encode($menu, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$data = urlencode($data);
// Send request Create the bottom menu bar
$url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token={$accessToken}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS , urldecode($data));
// Check the request return result
$result = json_decode($response, true);
if ($result[ 'errcode'] == 0) {
echo 'Creation of bottom menu bar successful';
} else {
echo 'Creation of bottom menu bar failed:' . $ result['errmsg'];