惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
Simon Willison's Weblog
Simon Willison's Weblog
H
Help Net Security
F
Fortinet All Blogs
H
Heimdal Security Blog
S
Schneier on Security
L
LangChain Blog
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
NISL@THU
NISL@THU
P
Palo Alto Networks Blog
J
Java Code Geeks
博客园 - 【当耐特】
The Last Watchdog
The Last Watchdog
W
WeLiveSecurity
www.infosecurity-magazine.com
www.infosecurity-magazine.com
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost
I
InfoQ
Recorded Future
Recorded Future
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
CERT Recently Published Vulnerability Notes
T
Tenable Blog
腾讯CDC
C
Check Point Blog
量子位
M
MIT News - Artificial intelligence
GbyAI
GbyAI
罗磊的独立博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
B
Blog
小众软件
小众软件
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
CXSECURITY Database RSS Feed - CXSecurity.com
Stack Overflow Blog
Stack Overflow Blog
P
Proofpoint News Feed
P
Privacy & Cybersecurity Law Blog
V2EX - 技术
V2EX - 技术
T
Threatpost
Engineering at Meta
Engineering at Meta
Attack and Defense Labs
Attack and Defense Labs
T
Tailwind CSS Blog
S
Securelist
The Cloudflare Blog
博客园 - 叶小钗
L
LINUX DO - 最新话题
T
Troy Hunt's Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
爱范儿
爱范儿

博客园 - SZW

微信 SDK + Senparc.AI + MCP 打造微信 AI 开发助手(二):在 Cursor、VS Code 等 IDE 中自动编写 微信 SDK + Senparc.AI + MCP 打造微信 AI 开发助手(一):网页版 Senparc.AI 系列教程(二):配置大模型,开始开发应用 Senparc.AI 系列教程(一):概要 Senparc 基础库全面适配 .NET 8.0 Senparc.Weixin SDK 微信平台开发教程(二十四):顺应 GenAI 应用,自动“续航”回复超长文本消息 微信 CLI 工具正式发布 v1.0 微信支付 V3 开发教程(一):初识 Senparc.Weixin.TenPayV3 [备忘]如何备份 VPN 文件 - SZW 动态 WebApi 引擎使用教程(3行代码完成动态 WebApi 构建) [备忘] 解决 rzc discover exited with code -2147450730 问题 “此 Url 可用于服务器 token 签名校验”提示 在开发环境内网穿透测试微信公众号 1个类,2个方法,3句代码,完成微信公众号开发的极简流程 [重要更新]微信小程序登录、用户信息相关接口调整:使用 wx.getUserProfile 取代 wx.getUserInfo [备忘]使用 .NET Core 模板生成时,在 .csproj 文件中使用条件编译的注意点 [备忘]处理错误:Your project does not reference ".NETFramework,Version=v4.5" framework. Add a reference to ".NETFramework,Version=v4.5" in the "TargetFrameworks" ... WeChatSampleBuilder V2.0 使用教程(网页版+桌面版) SCF(SenparcCoreFramework) 系列教程(一):项目介绍及快速搭建
微信新菜单类型 article_id 设置教程
SZW · 2022-05-07 · via 博客园 - SZW

  前不久, Senparc.Weixin SDK 跟随微信更新的步伐,上线了新的素材管理接口,其中也涉及到了 article_id 类型的自定义菜单接口。

  本文将演示如何使用新的菜单类型。

  官方文档传送门:https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Creating_Custom-Defined_Menu.html

方法一:直接撸代码

  在原有菜单设置代码的基础上(见:《自定义菜单接口说明》),将对应菜单的类型设置为 SingleArticleIdButton 或 SingleArticleViewLimitedButton 即可:

 1 ButtonGroup bg = new ButtonGroup();
 2 
 3 //二级菜单
 4 var subButton = new SubButton()
 5 {
 6     name = "二级菜单"
 7 };
 8 bg.button.Add(subButton);
 9 
10 subButton.sub_button.Add(new SingleArticleIdButton()
11 {
12     name = "article_id 按钮",
13     article_id = "YourArticleId"
14 });
15 
16 subButton.sub_button.Add(new SingleArticleViewLimitedButton()
17 {
18     name = "article_view_limited 按钮",
19     article_id = "YourArticleId"
20 });
21 
22 var result = CommonApi.CreateMenu(_appId, bg);

   其他使用方法和普通按钮一致。

  注意:article_id 即素材永久id。

方法二:UI 界面操作

  为了方便大家快速使用和体验 article_id 菜单按钮,Senparc.Weixin SDK 的 Sample 也已经更新了相应的 UI 操作界面。步骤如下:

1、 打开在线地址:https://sdk.weixin.senparc.com/

  当然您也可以使用源码在本地运行:

  https://github.com/JeffreySu/WeiXinMPSDK/tree/master/Samples/All/net6-mvc

2、 点击顶部菜单【工具箱】>【自定义菜单设置】

 

3、 点击页面下方按钮,展开可视化编辑区域:

   

  展开后:

 4、 填写AppId/Secret或直接使用AccessToken(注意添加IP白名单),点击对应按钮:

 

5、 选中需要设置的单元格,在右侧菜单类型中,选择【article_id】或【article_view_limited】,然后填写 ArticleId参数:

 

  设置完成后,点击【更新到服务器】,即可在手机端查看公众号菜单的变化。

   更多 Senparc.Weixin SDK 开发教程请参考:《Senparc.Weixin SDK 微信公众号 .NET 开发教程 索引》,感谢大家的关注,欢迎一起加入开源社区!

Senparc.Weixin SDK 微信公众号 .NET 开发教程 索引