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
- Add "WeChatWorkTool" to your INSTALLED_APPS setting like this:
# setting.py INSTALLED_APPS = [ ... 'WeChatWorkTool', ... ]
- Run python manage.py migrate to create the AccessToken models.
- 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)
- 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
- 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
- TextMessageObject
- MediaMessageObject
- TextCardMessageObject
- NewsMessageObject
- MarkDownMessageObject
- TaskCardBtnTemplate
- TaskCardMessageObject
Metadata
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-wechatwork-tool-0.0.3.tar.gz | 11.4 kB | Without provenance | Details for django-wechatwork-tool-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_wechatwork_tool-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for django_wechatwork_tool-0.0.3-py3-none-any.whl |
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
|
Security for django-wechatwork-tool 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.