In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "Force.com Wechat development series of how to achieve custom menu and voice recognition", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn "Force.com Wechat development series of how to achieve custom menu and speech recognition" this article.
Query menu
Similar to creating a menu, the query menu has its own API, in which ACESS_TOKEN needs to be obtained through the API described earlier, which usually expires after 2 hours:
Https://api.weixin.qq.com/cgi-bin/menu/get?access_token=[ACCESS_TOKEN]
To do this, we first obtain the real request URL similar to the following through the acquisition Access_Token described earlier:
Https://api.weixin.qq.com/cgi-bin/menu/get?access_token=RKkFQMHmXuTWPoCzEB9lYY_bksaBzxqKqE5FG0nW_74YXREheG3IyIoz9YvebQLI_6Vq9mD_rVD1iSXC1JzaBg
Run the link in browsers such as IE, save the corresponding file and open it to see the current menu structure of the Wechat account (garbled code may occur when viewing through different browsers, etc., which is due to the default coding display problem of the browser. Download it and view it in notepad to see the corresponding real text):
Delete menu
After creating a custom menu using the API, developers can also use the API to delete the currently used custom menu. The API for deleting the menu is as follows:
Https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=[ACCESS_TOKEN]
When correct, the returned JSON packet is as follows:
{"errcode": 0, "errmsg": "ok"}
Speech recognition
After the Wechat public account is verified by Wechat, you can obtain a voice recognition interface. After enabling the voice recognition feature, each time a user sends a voice to the Wechat account, Wechat will add a Recognition field to the pushed voice message XML packet. This field is the text content recognized by Evian. The following is an example of a voice XML packet when speech recognition is enabled:
13572909131234567890123456
For a description of each parameter, see the following figure:
The previous Force.com Wechat Development Series (3) the application test account and reply message already contain how to parse the value of the node, and the attribute is also included in the corresponding IncomingMsg class. The next thing you need to do is to add the processing code for the sound type message in the judgment message type section of the doPost method:
Else if (msgType.equals ('voice')) {rtnMsg = handleVoice (inMsg);}
Here, after recognizing that the message type is voice, we call the handleVoice method and pass the IncomingMsg object to process the sound. The handleVoice method code is as follows:
Private static String handleVoice (IncomingMsg msg) {String result = 'you said:' + msg.recognition; return composeTextReply (msg, result);}
The code reads the contents of the Recognition node in the XML question passed by the Tencent platform and returns it to the user. After saving the code, it attempts to send voice to the Wechat test account. The running effect is as follows:
These are all the contents of the article "Force.com Wechat Development Series on how to implement Custom menus and speech recognition". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.