模板消息相关接口#
- class wechatpy.client.api.WeChatTemplate(client=None)[源代码]#
包含了模板消息(旧)以及订阅通知(新)的接口,以
模板消息: https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html 订阅通知: https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/intro.html
旧的模板消息,接口不变 新的订阅通知模板,类似官方对订阅消息的取名 SubscribeMsg, 我们以 subscribe_message_template 命名予以区分
- add(template_id_short)#
【模板消息】获得模板ID 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#2
- 参数
template_id_short – 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式
- 返回
模板 ID
- add_subscribe_message_template(tid: str, keywords: List[int], description: str) str [源代码]#
【订阅通知】选用模板 (使用 tid 换取 template_id) 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html#addTemplate%E9%80%89%E7%94%A8%E6%A8%A1%E6%9D%BF
返回:添加至帐号下的模板 template_id,发送订阅通知时所需
- del_private_template(template_id)[源代码]#
【模板消息】删除模板 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#4
- 参数
template_id – 公众帐号下模板消息ID
- 返回
返回的 JSON 数据包
- del_subscribe_message_template(template_id: str)[源代码]#
【订阅通知】删除模板 (删除 template_id) 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html#addTemplate%E9%80%89%E7%94%A8%E6%A8%A1%E6%9D%BF
- get(template_id_short)[源代码]#
【模板消息】获得模板ID 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#2
- 参数
template_id_short – 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式
- 返回
模板 ID
- get_all_private_template()[源代码]#
【模板消息】获取模板列表 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#3
- 返回
返回的 JSON 数据包
- get_category() List[Dict] [源代码]#
【订阅通知】获取公众号类目 详情请参考: https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html#addTemplate%E9%80%89%E7%94%A8%E6%A8%A1%E6%9D%BF
返回数据参考: [
{ “id”: 616, “name”: “公交” }
]
- get_industry()[源代码]#
【模板消息】获取设置的行业信息 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#1
- 返回
返回的 JSON 数据包
- get_subscribe_message_template_keywords(tid: str) Tuple[int, List[Dict]] [源代码]#
【订阅通知】获取模板中的关键词 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html#addTemplate%E9%80%89%E7%94%A8%E6%A8%A1%E6%9D%BF
返回数据参考: (
10, # 公共模板列表总数 [ # 关键词列表
{ “kid”: 1, “name”: “物品名称”, “example”: “名称”, “rule”: “thing” }
]
)
- get_subscribe_message_template_titles(start: int = 0, limit: int = 30) Tuple[int, List[Dict]] [源代码]#
【订阅通知】获取所属类目的公共模板 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html#addTemplate%E9%80%89%E7%94%A8%E6%A8%A1%E6%9D%BF
返回数据参考: (
10, # 公共模板列表总数 [ # 模板标题列表
{ “tid”: 99, “title”: “付款成功通知”, “type”: 2, “categoryId”: “616” }
]
)
- get_subscribe_message_templates() List[Dict] [源代码]#
【订阅通知】获取私有模板列表 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html#addTemplate%E9%80%89%E7%94%A8%E6%A8%A1%E6%9D%BF
返回数据参考: [
- {
“priTmplId”: “9Aw5ZV1j9xdWTFEkqCpZ7mIBbSC34khK55OtzUPl0rU”, “title”: “报名结果通知”, “content”: “会议时间:{{date2.DATA}}
会议地点:{{thing1.DATA}} “,
“example”: “会议时间:2016年8月8日
会议地点:TIT会议室 “,
“type”: 2
}
]
- set_industry(industry_id1, industry_id2)[源代码]#
【模板消息】设置所属行业 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#0
- 参数
industry_id1 – 公众号模板消息所属行业编号
industry_id2 – 公众号模板消息所属行业编号
- 返回
返回的 JSON 数据包