Wechatworktool is a Django app
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-wechatwork-tool-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 385c0ba9e3324ecd65984ffe68c2c44c7631ebecd1a1e28d3e5a45ceb0228e69 |
|
MD5 | ba48f23524002e6ddd0e8ba622441937 |
|
BLAKE2b-256 | 208cb0c59004ac622d386e949f883a55fde7e01f7d5c0259e57eb144a4dbe0dd |
Close
Hashes for django_wechatwork_tool-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c6c3bdd03b318872e6fbbaae1d3d4e8ec691a506c7cf2954a370eee89bb44c2 |
|
MD5 | 63c940f9dd196de16a5b31e2c690d68f |
|
BLAKE2b-256 | b2c92f83d22a56f84039693304505fd3b04736642fdb4ad659360e3fc94c2e2d |