Home >Backend Development >PHP Tutorial >WeChat public platform custom menu development example_PHP tutorial
The WeChat public platform has launched a custom menu function. We can simply edit the custom menu directly in the background, or use the API to set the menu. Let me introduce the operation method below.
Tencent WeChat officially launched on March 19 Announce the custom menu function of the public platform. Currently, this function is only available to enterprises and institutions, and internal testing qualifications require application. For this new feature, only a few accounts have been activated. At this point, the commercial value of WeChat has been further explored.
Developers can use this feature to add a custom menu to the bottom of the conversation interface of public accounts. Users can click on the options in the menu to call up the corresponding reply information or web link.
Menu Creation
Interface Description
Create a custom menu on the WeChat client by POSTing a specific structure.
Request instructions
http request method: POST
https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN
The structure is actually a string in json format. I believe many friends are stuck here. How to post a structure to this interface address? The implementation code is as follows:
The code is as follows | Copy code |
public static void main(String[] args) throws Exception { |
Menu query
Interface Description
Query the currently used custom menu structure.
Request instructions
http request method: GET
https://api.weixin.qq.com/cgi-bin/menu/get?access_token=ACCESS_TOKEN
Return instructions
Corresponds to the creation interface, and the correct Json return result is:
The code is as follows
|
Copy code
|
||||
{"menu":{"button":[{"type":"click","name":"Today's song","key":"V1001_TODAY_MUSIC","sub_button":[]},{" type":"click","name":"Singer Profile","key":"V1001_TODAY_SINGER","sub_button":[]},{"name":"Menu","sub_button":[{"type" :"click","name":"hello word","key":"V1001_HELLO_WORLD","sub_button":[]},{"type":"click","name":"Like us"," key":"V1001_GOOD","sub_button":[]}]}]}}
Menu Delete
Request instructions
http request method: GET https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=ACCESS_TOKEN |
Return instructions
The code is as follows
|
Copy code |