Skip to main content

企业微信开发接口

Project description

企业微信接口

项目介绍

封装企业微信接口,发送消息.

安装教程

pip install work_weixin

使用说明

config.yml

---
# 部门ID
agentid: 10222222
# 钥匙
secret: Zjxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# 企业id
corpid: wxxxxxxxxxxxxxxxx

main.py

from work_weixin import Client
import getpass
import yaml
import os

if __name__ == '__main__':
    cfg_yml = yaml.load(open('./config.yml', 'r', encoding='utf-8'))
    if 'corpid' in cfg_yml:
        corpid = cfg_yml['corpid']
    else:
        corpid = input('请输入企业ID: ')
    if 'secret' in cfg_yml:
        secret = cfg_yml['secret']
    else:
        secret = getpass.getpass('请输入安全码: ')
    if 'agentid' in cfg_yml:
        agentid = cfg_yml['agentid']
    else:
        agentid = input('请输入组织代码: ')
    client = Client(corpid, secret, agentid)
    print(client.access_token)
    print(client.departments)
    print(client.users)
    partid = list(client.departments.keys())[0]
    msg = f"hello everyone in department of {client.departments[partid]['name']}"
    rtn = client.send_text_toparty(partid, msg)
    print(rtn['errmsg'])

    # rtn = client.upload_tmp(r'C:\Users\haifeng\tmp.jpg')
    # rtn = client.send_img(toparty=partid, media_id=rtn['media_id'])
    print(print(rtn['errmsg']))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for work-weixin, version 0.0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size work_weixin-0.0.2.2.tar.gz (10.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page