<!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>無標題文件</title>
#</head>
<?php
// 替換為你自己的AppID和AppSecret
$appId = 'wxd95fca43ae595a61';
$appSecret = '872a95a04a7e1bd78e3f#$appSecret = '872a95a04a7e1bd78e3f ';
// 取得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'];
######// 建立底部選單列的JSON結構######$menu = array( ###### 'button' => array(##### array(####### 'name' => ; array(###### array(###### gt; '安川',###### ' url' => 'https://www.example.com/submenu1',###### ),###### 'type' => 'click' ,###### 'name' => '發那科',###### 與#00, # ),####### ),####### ), '故障查詢',###### 'sub_button' => array(###### array(###### 'name' => '安川',## #### 'url' => 'https://www.example.com/submenu1',##### # #### 'type' = > 'click',###### 'name' => '發那科』,###'url' => 'https://www.example.com/submenu1',
# # # ),
array(
'name' => '故障查詢',
'sub_button'
### 'type' => 'view',
'name' => '安川',
## 100 ', ), array(# 'name' => '發那科',
'url' => 'https://www.example.com/submenu1',
# ),
),
);
#// 將選單結構轉換為JSON字串並進行URL編碼#$data = json_encode($menu, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);$data = urlencode($data);#// 發送請求請求建立底部選單列
$url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token={$accessToken}";
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch) ;
// 檢查請求回傳結果$result = json_decode($response, true);if ($result[ 'errcode'] == 0) { echo '建立底部功能表列成功';} else { echo '建立底部功能表列失敗:' . $ result['errmsg'];
}
#>
#以上程式碼運行後,顯示成功,但不能建立微信公眾號底部選單列