Remember a pit of WeChat public account personalized menu

Rough process: The official account menu of the unit has been in normal use since last year's version was launched. Now there is a plan to adjust the menu of the official account, and use the functions that have been designed before to regenerate the menu. There is no problem with the normal menu, but the personalized menu is always unsuccessful.

The reason and error appearance of WeChat newspaper are as follows:

Reason for the error: 65316 The menu of the official account has too many domain name jumps (up to 3 domain name links)

Appearance : The menu of last year's version is generated every time, and the newly set menu is always invalid.

Note: Last year's version of the menu included links to the domain names on 3. Now this menu adjustment has replaced two of the domain names for some reasons.

debugging:

1. Since WeChat reports that there are at most 3 domain name links, try to remove the link of the new menu, and finally found that the link in the original menu must be used in the new menu to succeed, otherwise even if any link is changed, that is Using a new link will report an error of 65316. However, there are really no more than 3 domain names in my personalized menu settings, not even 1 domain name. After debugging for more than half a day, I still can't find the reason.

2. Exactly the same code without any problem in the test number.

solve:

Today, I continued to look at the WeChat document, and I accidentally saw the interface where you can view the custom menu, so I tried it, and I immediately understood the reason. It turns out that WeChat will automatically save the personalized menus generated in the past, and it will be saved every time it is generated. Only one copy of the normal menu is reserved. It is equivalent that the personalized menu is the "add" method, and the ordinary menu is the "override" method, that is, the modification method. In this way, the 3 domain name links of 65316 judged by WeChat are judged in all personalized menus, not just the personalized menu configuration to be generated currently.

Once you understand the reason, the solution is simple. Delete all personalized menus, regenerate personalized menus again, and the problem is solved.

            // Get all menus, including personalized menus 
            var MenuResult = httpClient.GetStringAsync( string .Format( " https://api.weixin.qq.com/cgi-bin/menu/get?access_token={0} " , WxApiRepository .GetApi.token)).Result;            
             var mlist = (JsonConvert.DeserializeObject(MenuResult) as  dynamic ).conditionalmenu as IEnumerable< object > ;
             foreach ( var p in mlist)
            {
                // Personalized menu 
                var obj = JsonConvert.DeserializeObject<conditionalmenu> (p.ToString());
                Response.Write(p);
                // Delete personalized menu 
                var result = httpClient.PostAsJsonAsync( string .Format( " https://api.weixin.qq.com/cgi-bin/menu/delconditional?access_token={0} " , WxApiRepository.GetApi.token ), new { menuid = obj.menuid }).Result;
                Response.Write("结果" + result + Environment.NewLine);                
            }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325814493&siteId=291194637