1234567891011121314151617181920212223242526272829303132333435363738 |
- import requests
- import json
- import datetime
- def datetime_now():
- datetimenow = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
- return datetimenow
- def hik_permissiongroupspersons(hik_accesstoken,groupId,jobids):
- headers = {"content-type": "application/json"}
- data = {
- "groupId": groupId,
- "employeeNos": jobids,
- "autoIssue": "true"
- }
- response = requests.post(
- url="https://api2.hik-cloud.com/api/v1/open/accessControl/permissionGroups/actions/addPersons?access_token=%s" % hik_accesstoken,
- headers=headers,
- data=json.dumps(data)
- )
- if response.json()["code"] == 200:
- print("%s,权限组绑定人员成功"%(datetime_now()))
- else:
- print(datetime_now(),jobids,response.json()["message"])
- # return response.json()
- # if __name__ == '__main__':
- # with open("config.json") as f:
- # data = json.load(f)
- # client_id = data["client_id"]
- # client_secret = data["client_secret"]
- # groupId = data["groupId"]
- # accesstoken = hik_access_token(client_id, client_secret)
- #
- # jobids = ["10","11"]
- # hik_permissiongroupspersons(accesstoken,jobids)
|