# 用 Python 发送企业微信消息
支持发送:
- 文本
- 文件
- 图片
- MarkDown
## 安装
```sh
pip install wechat-enterprise-sdk
```
## 使用
获取的 access_token 会保存在 ./tmp/cache.json 里面,避免高频率获取 access_token。
```python
from wechat_enterprise import WechatEnterprise
we = WechatEnterprise(
corpid="ww2563f***********", # 企业 ID
appid="100****3", # 企业应用 ID
corpsecret="*********************", # 企业应用 Secret
)
#接收者 ID,在企业微信通讯录中查看
receivers = ["ZhengZheng", "DaZhengGe"]
# 发送 文本
we.send_text("来息 somenzz 的消息", receivers)
# 发送 Markdown
we.send_markdown("# Markdown", receivers)
# 发送图片
we.send_image("/Users/aaron/Downloads/images.jpeg", receivers)
# 发送文件
we.send_file("./wechat_enterprise.py", receivers)
# 根据手机号获取企业微信账号:
userid = we.get_userid("138********")
we.send_text("hello",[userid,])
```
## todo
添加企业微信的其他实用功能
## 联系我
添加微信 「somenzz-enjoy」 备注 「github」
个人公众号 「Python七号」,微信搜一搜关注。
Raw data
{
"_id": null,
"home_page": "https://github.com/somenzz/wechat_enterprise",
"name": "wechat-enterprise-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python wechat enterprise, wechat_enterprise, send message",
"author": "somenzz",
"author_email": "somenzz@163.com",
"download_url": "https://files.pythonhosted.org/packages/db/c2/49a9b044a67084fdbf161c74ae635664986ecb93b721de5b31bceb89621b/wechat_enterprise_sdk-0.4.2.tar.gz",
"platform": null,
"description": "# \u7528 Python \u53d1\u9001\u4f01\u4e1a\u5fae\u4fe1\u6d88\u606f\n\n\u652f\u6301\u53d1\u9001\uff1a\n- \u6587\u672c\n- \u6587\u4ef6\n- \u56fe\u7247\n- MarkDown\n\n## \u5b89\u88c5\n```sh\npip install wechat-enterprise-sdk\n```\n\n## \u4f7f\u7528\n\n\u83b7\u53d6\u7684 access_token \u4f1a\u4fdd\u5b58\u5728 ./tmp/cache.json \u91cc\u9762\uff0c\u907f\u514d\u9ad8\u9891\u7387\u83b7\u53d6 access_token\u3002\n\n```python\nfrom wechat_enterprise import WechatEnterprise\nwe = WechatEnterprise(\n corpid=\"ww2563f***********\", # \u4f01\u4e1a ID\n appid=\"100****3\", # \u4f01\u4e1a\u5e94\u7528 ID\n corpsecret=\"*********************\", # \u4f01\u4e1a\u5e94\u7528 Secret\n)\n\n#\u63a5\u6536\u8005 ID\uff0c\u5728\u4f01\u4e1a\u5fae\u4fe1\u901a\u8baf\u5f55\u4e2d\u67e5\u770b\nreceivers = [\"ZhengZheng\", \"DaZhengGe\"]\n# \u53d1\u9001 \u6587\u672c\nwe.send_text(\"\u6765\u606f somenzz \u7684\u6d88\u606f\", receivers)\n# \u53d1\u9001 Markdown\nwe.send_markdown(\"# Markdown\", receivers)\n# \u53d1\u9001\u56fe\u7247\nwe.send_image(\"/Users/aaron/Downloads/images.jpeg\", receivers)\n# \u53d1\u9001\u6587\u4ef6\nwe.send_file(\"./wechat_enterprise.py\", receivers)\n# \u6839\u636e\u624b\u673a\u53f7\u83b7\u53d6\u4f01\u4e1a\u5fae\u4fe1\u8d26\u53f7\uff1a\nuserid = we.get_userid(\"138********\")\nwe.send_text(\"hello\",[userid,])\n```\n\n## todo\n\n\u6dfb\u52a0\u4f01\u4e1a\u5fae\u4fe1\u7684\u5176\u4ed6\u5b9e\u7528\u529f\u80fd\n\n## \u8054\u7cfb\u6211\n\n\u6dfb\u52a0\u5fae\u4fe1 \u300csomenzz-enjoy\u300d \u5907\u6ce8 \u300cgithub\u300d\n\n\u4e2a\u4eba\u516c\u4f17\u53f7 \u300cPython\u4e03\u53f7\u300d\uff0c\u5fae\u4fe1\u641c\u4e00\u641c\u5173\u6ce8\u3002\n",
"bugtrack_url": null,
"license": "MIT",
"summary": null,
"version": "0.4.2",
"project_urls": {
"Homepage": "https://github.com/somenzz/wechat_enterprise"
},
"split_keywords": [
"python wechat enterprise",
" wechat_enterprise",
" send message"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "10e20daeeebf88087a1da4256229a7a9aa32e4bbf24da5d48fbcaa5e28454e7e",
"md5": "60755ecaf40e949c675cd6f29eaf5ef9",
"sha256": "893ca3c1f620918ef0ed697e0c37253c2e02d33e3efd279a58f196e6bc67da43"
},
"downloads": -1,
"filename": "wechat_enterprise_sdk-0.4.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "60755ecaf40e949c675cd6f29eaf5ef9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5869,
"upload_time": "2024-08-28T01:18:36",
"upload_time_iso_8601": "2024-08-28T01:18:36.715369Z",
"url": "https://files.pythonhosted.org/packages/10/e2/0daeeebf88087a1da4256229a7a9aa32e4bbf24da5d48fbcaa5e28454e7e/wechat_enterprise_sdk-0.4.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "dbc249a9b044a67084fdbf161c74ae635664986ecb93b721de5b31bceb89621b",
"md5": "77e8f4956f4c6ea44e40950841bb6b78",
"sha256": "285ff4435cc6175f8a070e7894f67e88a1ba6d69f3cf770b9543de55e29519f4"
},
"downloads": -1,
"filename": "wechat_enterprise_sdk-0.4.2.tar.gz",
"has_sig": false,
"md5_digest": "77e8f4956f4c6ea44e40950841bb6b78",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5758,
"upload_time": "2024-08-28T01:18:38",
"upload_time_iso_8601": "2024-08-28T01:18:38.429570Z",
"url": "https://files.pythonhosted.org/packages/db/c2/49a9b044a67084fdbf161c74ae635664986ecb93b721de5b31bceb89621b/wechat_enterprise_sdk-0.4.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-28 01:18:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "somenzz",
"github_project": "wechat_enterprise",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "requests",
"specs": []
},
{
"name": "requests_toolbelt",
"specs": []
}
],
"lcname": "wechat-enterprise-sdk"
}