Python+Flask微信企业号开发之发送消息

    

一 . 前言html

    微信公共号有个很好的Python SDK :wechatpy 里面封装了一些关于Python开发微信工做号的API。具体能够参见web

    http://wechatpy.readthedocs.org/zh_CN/master/install.html 。可是对于开发微信企业号却没有明确的给出文档指南。固然webchatpy里面也封装了关于操做企业号的api

 1. 安装wechatpy微信

      pip install wechatpyspa

 2. 申请微信企业号code

 3. 查看微信企业号的corp_id 和 secretorm

 

4. 发送消息htm

from wechatpy.enterprise WeChatClient

from wechatpy.enterprise.client.api WeChatUser

from config import *


client = WeChatClient(corp_id=CORP_ID,secret=CORP_SECRET)
def send_message():
    title = ""
    content = ""
    client.message.send_text("0", "user_id", content=u"标题:{0}\n 内容:{1}".format(title, content))


 5. 获取通信录中的用户信息ip

user = wechatuser.get(client=client)
print(user)
相关文章
相关标签/搜索