WeChat public platform development: Description of personalized menu interfaces

Source: Internet
Author: User
This update upgrades Senparc. Weixin. MP to v13.5.2, depending on Senparc. Weixin version 4.5.4 .. Both the NET4.5 (master). NET4.0 branches have been synchronously updated. Not long ago, the personalized menu interface was launched, and the Senparc. Weixin SDK was also updated.

This update upgrades Senparc. Weixin. MP to v13.5.2, depending on Senparc. Weixin version 4.5.4 .. Both the NET4.5 (master) and. NET4.0 branches have been synchronously updated.

Because the personalized menu changes greatly, the entire menu interface has been reconstructed with the maximum area so far (backward compatible ).

Compared with the previous custom menu, the entire menu-related functions are comprehensively organized for the file structure ,:

Interface

All Menu interfaces are included in the CommonAPIs/Menu Directory. the CommonApi category contains three class files:

File name Description
CommonApi. Menu. Common. cs Common menu methods
CommonApi. Menu. Conditional. cs Personalized menu
CommonApi. Menu. Custom. cs General custom menu

Menu interface file

The custom menu interface ensures backward compatibility. if you have previously developed a custom menu function project, you can upgrade it with confidence.

The content of the personalized menu class is as follows:

/* ---------------------------------------------------------------- Copyright (C) 2015 Senparc File name: CommonApi. menu. function description of the Conditional File: custom menu interface creation ID: Senparc-20151222 modify ID: Senparc-20151222 modify description: v13.5.1 add personalized menu interface handler * // * API: http://mp.weixin.qq.com/wiki/0/c48ccd12b69ae023159b4bfaa7c39c20.html */using Senparc. weixin. entities; using Senparc. weixin. helpers; using Senparc. weixin. MP. entities; using Senparc. weixin. MP. entities. menu; namespace Senparc. weixin. MP. commonAPIs {public partial class CommonApi {////// Create a Xinhua menu //////AccessToken or AppId. When the value is AppId, if the AccessToken is incorrect, it is automatically obtained once. If it is null, obtain the first registered AppId.///Menu content///
 Public static CreateMenuConditional (string accessTokenOrAppId, ConditionalButtonGroup buttonData, int timeOut = Config. TIME_OUT) {return ApiHandlerWapper. TryCommonApi (accessToken => {var urlFormat = "https://api.weixin.qq.com/cgi-bin/menu/addconditional? Access_token = {0} "; var jsonSetting = new JsonSetting (true); return CommonJsonSend. Send
 
  
(AccessToken, urlFormat, buttonData, timeOut: timeOut, jsonSetting: jsonSetting) ;}, accessTokenOrAppId );} # region GetMenu/* use the common custom menu query interface to obtain the default menu and all the personalized menu information. for details, see the description of the custom menu query interface *////
  /// Test the personalized menu matching result //////
  ///
  It can be the fan's OpenID or the fan's number.///
  Public static MenuTryMatchResult TryMatch (string accessTokenOrAppId, string userId) {return ApiHandlerWapper. TryCommonApi (accessToken => {var url = string. Format ("https://api.weixin.qq.com/cgi-bin/menu/delconditional? Access_token = {0} ", accessToken); var data = new {user_id = userId}; return CommonJsonSend. Send
  
   
(AccessToken, url, data, CommonJsonSendType. POST) ;}, accessTokenOrAppId) ;}# endregion ///
   /// Delete a menu //////
   ///
   Menu Id///
   Public static WxJsonResult DeleteMenuConditional (string accessTokenOrAppId, string menuId) {return ApiHandlerWapper. TryCommonApi (accessToken => {var url = string. Format ("https://api.weixin.qq.com/cgi-bin/menu/delconditional? Access_token = {0} ", accessToken); var data = new {menuId = menuId}; return CommonJsonSend. send (accessToken, url, data, CommonJsonSendType. POST) ;}, accessTokenOrAppId);}/* you can use the common custom menu deletion interface to delete all custom menus (including default menus and all personalized menus ), see the description of the deletion interface in the custom menu. */}}
  
 


In the public menu method, the GetButtonGroup () method adds a parameter: buttonGroup, which is used to specify the menu button list type (which belongs to the custom menu or custom menu ).

  

Entity

Changes to object classes are reflected in the Entities/Menu Directory. the IButtonGroupBase interface and ButtonGroupBase base class are created. The ButtonGroup (custom menu) and ConditionalButtonGroup (personalized menu) buttons are inherited from ButtonGroupBase.

All button types in the Entities/Menu/Buttons/directory are common.

Return type

The returned types are all in the Entities/JsonResult/Menu/directory:

For more public platform development: For more information about personalized menu interfaces, see PHP!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.