Can anyone help me to see the error?
P粉524549047
P粉524549047 2023-12-14 09:52:50
0
0
369

<!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));

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch) ;

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

}

?>

After the above code is run, it is displayed successfully, but the bottom menu bar of the WeChat official account cannot be created

P粉524549047
P粉524549047

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!