123456789101112131415161718192021222324252627 |
- import requests
- import json
- import datetime
- def datetime_now():
- datetimenow = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
- return datetimenow
- def hik_adduser(hik_access_token,jobid,name):
- data = {
- "employeeNo": jobid,
- "personName": name
- }
- headers = {"content-type": "application/json"}
- response =requests.post(url="https://api2.hik-cloud.com/api/v1/open/basic/persons/create?access_token=%s"%hik_access_token,headers=headers,data=json.dumps(data))
- if response.json()["code"] == 200:
- print("%s,%s(%s)用户添加成功"%(datetime_now(),name,jobid))
- else:
- print("%s,%s(%s)%s"%(datetime_now(),name,jobid,response.json()["message"]))
- # 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"]
- # hik_accesstoken = hik_access_token(client_id, client_secret)
- # hik_adduser(hik_accesstoken,"2254","lisand")
|