MCPcopy Create free account
hub / github.com/doraemonext/wechat-python-sdk / send_template_message

Method send_template_message

wechat_sdk/basic.py:796–842  ·  view source on GitHub ↗

发送模版消息 详情请参考 http://mp.weixin.qq.com/wiki/17/304c1885ea66dbedf7dc170d84999a9d.html :param user_id: 用户 ID, 就是你收到的 WechatMessage 的 source (OpenID) :param template_id: 模板ID :param data: 模板消息数据 (dict形式),示例如下: { "first": { "value

(self, user_id, template_id, data, url='', topcolor='#FF0000')

Source from the content-addressed store, hash-verified

794 )
795
796 def send_template_message(self, user_id, template_id, data, url='', topcolor='#FF0000'):
797 """
798 发送模版消息
799 详情请参考 http://mp.weixin.qq.com/wiki/17/304c1885ea66dbedf7dc170d84999a9d.html
800 :param user_id: 用户 ID, 就是你收到的 WechatMessage 的 source (OpenID)
801 :param template_id: 模板ID
802 :param data: 模板消息数据 (dict形式),示例如下:
803 {
804 "first": {
805 "value": "恭喜你购买成功!",
806 "color": "#173177"
807 },
808 "keynote1":{
809 "value": "巧克力",
810 "color": "#173177"
811 },
812 "keynote2": {
813 "value": "39.8元",
814 "color": "#173177"
815 },
816 "keynote3": {
817 "value": "2014年9月16日",
818 "color": "#173177"
819 },
820 "remark":{
821 "value": "欢迎再次购买!",
822 "color": "#173177"
823 }
824 }
825 :param url: 跳转地址 (默认为空)
826 :param topcolor: 顶部颜色RGB值 (默认 '#FF0000' )
827 :return: 返回的 JSON 数据包
828 """
829 unicode_data = {}
830 if data:
831 unicode_data = self._transcoding_dict(data)
832
833 return self.request.post(
834 url='https://api.weixin.qq.com/cgi-bin/message/template/send',
835 data={
836 'touser': user_id,
837 "template_id": template_id,
838 "url": url,
839 "topcolor": topcolor,
840 "data": unicode_data
841 }
842 )
843
844 @property
845 def access_token(self):

Callers 1

Calls 2

_transcoding_dictMethod · 0.80
postMethod · 0.80

Tested by 1