哪位大神幫忙看一下錯誤
P粉524549047
P粉524549047 2023-12-14 09:52:50
0
0
238

<!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}";

#$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDSDS , urldecode($data));


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'];


}

#>

#以上程式碼運行後,顯示成功,但不能建立微信公眾號底部選單列

P粉524549047
P粉524549047

全部回覆(0)
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!