Skip to main content

WeChatWorkTool

Wechatworktool is a Django app,which is used to facilitate the internal application development of enterprise wechat and call enterprise wechat interface faster

Quick start

Install pip install django-wechatwork-tool

  1. Add "WeChatWorkTool" to your INSTALLED_APPS setting like this:
    # setting.py
    INSTALLED_APPS = [
        ...
        'WeChatWorkTool',
        ...
    ]
    
  2. Run python manage.py migrate to create the AccessToken models.
  3. Start the development server and visit http://127.0.0.1:8000/admin/ to create a AccessToken (need WeChatWork's corpid and an app secret of WeChatWork)
  4. Call where needed:
    ...
    from WeChatWorkTool import tool
    ...
    app=tool.CorpApp('sap')
    print(app.app_info())
    # Details of WeChatWork internal applications
    print(app.get_user('FS0397'))
    # Get employee details through employee ID
    
  5. Application verification and callback example
    import json
    from django.http import HttpResponse
    from django.views.decorators.csrf import csrf_exempt
    
    from WeChatWorkTool import tool
    
    
    @csrf_exempt
    def call_back(request):
        """WeChatWork messqge callback Simple Example"""
        if request.method == 'GET':
            # Authentication  url
            data = request.GET.dict()
            return HttpResponse(tool.call_back_verify(data, 'sap'))
    
        if request.method == 'POST':
            url_data = request.GET.dict()
            cb = tool.CorpApp('sap').call_back_data(url_data, request.body)
            return HttpResponse(json.dumps(cb), content_type="application/json")
    

WeChatWorkTool

CorpApp: WeChatWorks custom application

def app_info(self):
    """
    get this app info
    :return: App Info
    """

def get_userid_by_code(self, code):
    """get userid by code锛孖t's just for webpage authorization link

    :param code: in webpage authorization link
    :return:UserId
    """

def get_user(self, userid):
    """get user info

    :param userid: WeChatWork user's id
    :return: a dict that user info
    """

def get_user_tag_list(self):
    """get user tag list

    :return: user tag list
    """

def get_department_user_simplelist(self, department_id, fetch_child=False):
    """get user simplelist by department id

    :param department_id:
    :param fetch_child:
    :return
        For success example:
            {
                "errcode" : 0,
                "errmsg" : "ok",
                "invaliduser" :"",
                "invalidparty" : "",
                "invalidtag": ""
            }

        For error example:
            {
                "errcode" : 0,
                "errmsg" : "ok",
                "invaliduser" : [userid1,userid2],
                "invalidparty" : [partyid1,partyid2],
                "invalidtag": [tagid1,tagid2]
            }
    """

def get_department_user_list(self, department_id, fetch_child=False):
    """get user list by department id

    :param department_id:
    :param fetch_child:
    :return:
    """

def get_department(self, id):
    """get department info list

    :param id: WeChatWork department's id
    :return:
    """

def SendMsg(self, msgobj, touser: list = [], toparty: list = [], totag: list = [],
            safe=0, enable_id_trans=0,
            enable_duplicate_check=0,
            duplicate_check_interval=1800):
    """

    :param touser:
    :param toparty:
    :param totag:
    :param msgobj:
    :param safe:
    :param enable_id_trans:
    :param enable_duplicate_check:
    :param duplicate_check_interval:
    :return:
    """

Massage object

The message type corresponds to the message type of WeChatWork

  1. TextMessageObject
  2. MediaMessageObject
  3. TextCardMessageObject
  4. NewsMessageObject
  5. MarkDownMessageObject
  6. TaskCardBtnTemplate
  7. TaskCardMessageObject

Release files for django-wechatwork-tool 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-wechatwork-tool 0.0.3
File Size Uploaded
django-wechatwork-tool-0.0.3.tar.gz 11.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-wechatwork-tool 0.0.3
File Interpreter ABI Platform
django_wechatwork_tool-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 26.3 kB

Release files / django-wechatwork-tool-0.0.3.tar.gz

Download URL django-wechatwork-tool-0.0.3.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
385c0ba9e3324ecd65984ffe68c2c44c7631ebecd1a1e28d3e5a45ceb0228e69
BLAKE2b-256 checksum
How to use checksums
208cb0c59004ac622d386e949f883a55fde7e01f7d5c0259e57eb144a4dbe0dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.5

Release files / django_wechatwork_tool-0.0.3-py3-none-any.whl

Download URL django_wechatwork_tool-0.0.3-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c6c3bdd03b318872e6fbbaae1d3d4e8ec691a506c7cf2954a370eee89bb44c2
BLAKE2b-256 checksum
How to use checksums
b2c92f83d22a56f84039693304505fd3b04736642fdb4ad659360e3fc94c2e2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.5

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page