微信公眾賬號服務號自定義選單配置與實現

2021-06-19 17:40:18 字數 1391 閱讀 3844

下面po上我的實現方法,以備後用。

<?php 

/** * get access token

* @author ren kan */

header("content-type: text/html; charset=utf-8");

$content = file_get_contents($url);

$info = json_decode($content);

echo $info->access_token;

?>

$access_token = "the access token got above";

/* 這裡是檢視型別的自定義選單反饋條目

*/$data = ',,]

},,]},

,]}]

}';echo $data;

$ch = curl_init();

curl_setopt($ch, curlopt_url, "");

curl_setopt($ch, curlopt_customrequest, "post");

curl_setopt($ch, curlopt_ssl_verifypeer, false);

curl_setopt($ch, curlopt_ssl_verifyhost, false);

curl_setopt($ch, curlopt_useragent, 'mozilla/5.0 (compatible; msie 5.01; windows nt 5.0)');

curl_setopt($ch, curlopt_followlocation, 1);

curl_setopt($ch, curlopt_autoreferer, 1);

curl_setopt($ch, curlopt_postfields, $data);

curl_setopt($ch, curlopt_returntransfer, true);

echo $ch;

$tmpinfo = curl_exec($ch);

if (curl_errno($ch))

curl_close($ch);

echo $tempinfo;

/**/

以上**構建以後,只需要終端利用命令php shellname.php依次執行即可。

效果在公眾賬號頁面過會就會看到更新了。

效果如下:

感謝 微相框公眾賬號提供支援。

www.vxiangkuang.com

微信公眾平台自定義選單

介面呼叫請求說明 http請求方式 get引數說明 引數是否必須 說明grant type 是獲取access token填寫client credential 是第三方使用者唯一憑證 secret 是返回說明 引數 說明access token 獲取到的憑證 expires in 憑證有效時間,單...

微信公眾平台 自定義選單

服務號和通過認證的訂閱號可以申請自定義選單。自定義選單介面可實現click view兩種型別的按鈕。1 建立選單 const createmenuurl function createmenus accesstoken string tjsonobject var url string j tjso...

PHP微信公眾平台自定義選單

請求說明 http請求方式 get 現在你的token已經獲取成功了,下來就是相關的 實現了。public function createmenu ch curl init curl setopt ch,curlopt url,curl setopt ch,curlopt customrequest...