Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to customize menu creation Interface in web

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to customize the menu creation interface in web, which is very detailed and has certain reference value. Friends who are interested must read it!

A custom menu interface can implement many types of buttons, as follows:

1. Click: click push event after the user clicks the click type button, the Wechat server will push the structure with the message type event to the developer through the message interface (refer to the message interface guide), and with the key value entered by the developer in the button, the developer can interact with the user through the custom key value. 2. View: when a URL user clicks the view type button, the Wechat client will open the web page URL entered by the developer in the button, which can be combined with the API for authorizing access to basic user information to obtain basic user information. 3. Scancode_push: after the user clicks the button on the ScanCode push event, the Wechat client will call up the scan tool, display the scan result after completing the scan operation (in the case of URL, enter URL), and transmit the scan result to the developer, who can send a message. 4. Scancode_waitmsg: after the push event is scanned and the "receiving message" prompt box pops up, Wechat client will set up the scan tool. After completing the scan operation, it will transmit the scan result to the developer, put away the scan tool at the same time, then pop up the "receiving message" prompt box, and then may receive a message from the developer. 5. Pic_sysphoto: after the pop-up system takes pictures and sends pictures, the user clicks the button, and the Wechat client will set up the system camera. After the photo operation is completed, the Wechat client will send the taken photos to the developer, push the event to the developer, put away the system camera at the same time, and then may receive messages from the developer. 6. Pic_photo_or_album: when a user clicks a button to take a photo or send an album, the Wechat client will pop up a selector for the user to choose "take a picture" or "choose from a mobile album". After the user chooses, he or she will follow the other two processes. 7. Pic_weixin: after the user clicks the button on the pop-up Wechat album distributor, the Wechat client will call up the Wechat album, complete the selection operation, send the selected photos to the developer's server, push the event to the developer, put away the album at the same time, and then may receive a message from the developer. 8. Location_select: after the user clicks the button in the pop-up geolocation selector, the Wechat client will bring up the geolocation selection tool. After completing the selection operation, it will send the selected geolocation to the developer's server, put away the location selection tool at the same time, and then may receive messages from the developer. 9. Media_id: send messages (except text messages) after the user clicks the media_id type button, the Wechat server will send the permanent material id filled in by the developer to the user under the corresponding material. The permanent material type can be picture, audio, video, picture and text message. Please note: the permanent footage id must be a legitimate id obtained after uploading the "material Management / add permanent footage" interface. 10. View_limited: when a URL user clicks the view_limited type button, the Wechat client will open the URL corresponding to the permanent footage id entered by the developer in the button. The permanent footage type only supports picture and text messages. Please note: the permanent footage id must be a legitimate id obtained after uploading the "material Management / add permanent footage" interface.

Please note that all events from 3 to 8 only support Wechat users of Wechat iPhone5.4.1 and above Android5.4. Users of the old version of Wechat will not respond after clicking, and developers will not be able to receive event push normally. 9 and 10 are event types specially prepared for Subscription account who is not certified by Wechat (specifically, the qualification verification) of a third-party platform. They do not have event push, and their capabilities are relatively limited. Other types of official accounts do not need to be used.

API call request description

Http request method: POST (please use https protocol) https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN

Example of requests for click and view

{

"button": [

{

"type": "click"

"name": "Today's Song"

"key": "V1001_TODAY_MUSIC"

}

{

"name": "menu"

"sub_button": [

{

"type": "view"

"name": "search"

"url": "http://www.soso.com/""

}

{

"type": "view"

"name": "Video"

"url": "http://v.qq.com/""

}

{

"type": "click"

"name": "praise us"

"key": "V1001_GOOD"

}]

}]

}

Examples of requests for other new button types

{

"button": [

{

"name": "scan code"

"sub_button": [

{

"type": "scancode_waitmsg"

"name": "Code scan Tip"

"key": "rselfmenu_0_0"

"sub_button": []

}

{

"type": "scancode_push"

"name": "Code scan push event"

"key": "rselfmenu_0_1"

"sub_button": []

}

]

}

{

"name": "send pictures"

"sub_button": [

{

"type": "pic_sysphoto"

"name": "system photo and send pictures"

"key": "rselfmenu_1_0"

"sub_button": []

}

{

"type": "pic_photo_or_album"

"name": "take photos or send pictures from photo albums"

"key": "rselfmenu_1_1"

"sub_button": []

}

{

"type": "pic_weixin"

"name": "send pictures from Wechat albums"

"key": "rselfmenu_1_2"

"sub_button": []

}

]

}

{

"name": "send location"

"type": "location_select"

"key": "rselfmenu_2_0"

}

{

"type": "media_id"

"name": "picture"

"media_id": "MEDIA_ID1"

}

{

"type": "view_limited"

"name": "Teletext message"

"media_id": "MEDIA_ID2"

}

]

}

Parameter description

Whether the parameter must be specified

Button is an array of first-level menus. The number should be 1-3.

Sub_button No second-level menu array, the number should be 1-5

Type is the response action type of the menu

Name is a menu title with no more than 16 bytes and a submenu with no more than 40 bytes

Click types such as keyclick must have a menu key value, which is used for message API push, with no more than 128 bytes.

Urlview type must be linked to a web page. Users can click the menu to open the link, which is no more than 1024 bytes.

Media_idmedia_id type and view_limited type must call the legal media_id returned by the new permanent material API

Return the result

When correct, the returned JSON packet is as follows:

{"errcode": 0, "errmsg": "ok"}

The JSON packet returned in case of error is as follows (invalid menu name length is an example):

{"errcode": 40018, "errmsg": "invalid button name size"}

Function createMenu () {$token = $this- > gettoken (); echo $token; $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=$token"; $post ='{"button": [{"type": "click", "name": "Today's song", "key": "V1001_TODAY_MUSIC"}, {"name": "menu", "sub_button": [{"type": "view" "name": "search", "url": "http://www.soso.com/"}, {" type ":" view "," name ":" Video "," url ":" http://v.qq.com/"} {"type": "click", "name": "praise us", "key": "V1001_GOOD"}]}]}' $res = $this- > curl_post ($url,$post); var_dump ($res);} function curl_post ($url,$data) {$curl = curl_init (); curl_setopt ($curl, CURLOPT_URL, $url); curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, FALSE) If (! empty ($data)) {curl_setopt ($curl, CURLOPT_POST, 1); curl_setopt ($curl, CURLOPT_POSTFIELDS, $data);} curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1); $res = curl_exec ($curl); curl_close ($curl); return $res }} these are all the contents of the article "how to customize menu creation Interface in web". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report