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)
相關文章
相關標籤/搜索