this example, we share with you the specific code for python3 to realize the daily number sent by the public number, for your reference, the specific content is as follows:

steps are: first apply for the public number, find . After reading that is mainly through the Corpid (enterprise key) and corpsecret (application key) to obtain login token, enter each URL operation through the token.

I use the enterprise WeChat, so there is a department. Other public numbers are similar. The results are as follows:

 coding:utf-8 import # -*- -*- requests import JSON import time url0 def (get_group_id =''): # view department and member of the values_address = {'corpid': 'your corpid','corpsecret', mail list corpsecret', req} = (url0, params=values_address) data = json.loads (req.text) token = data["access_token" url_department= " Access_token=" +token r_department=requests.get (url_department) # Department (result_department=r_department.json) result_department_no=result_department['department'] print ("* * * has access to Department The following information: "item in result_department_no: print (for)" [Department]: "item['id']," [] ", the name of the Department: item['name']," [father] Department: ", item['parentid']," [number]: "(print, item['order'])" * * * has access to members information as follows: for) I in range (len (result_department_no)): i=i+1 url_member = access_token=%s& department_id=%s& " Fetch_child=FETCH_CHILD"% (token, I) # member r_member (url_member) = requests.get result_member = r_member.json (result_member_no) = result_member['userlist'] for item in result_member_no: print ("id]", item['userid'] "member," [member name] "item['name']," [Department]: "item['department'], return result_department_no, result_member_no def uplo) (ad_img): values_address = {'corpid':''corpsecret'': your corpsecret', corpsecret', req} = (url0, params=values_address) data = json.loads (req.text) token = data[("print" access_token "] * * * has access to" token. ") url_upimg=? Access_token=%s& type=%s% (token," image "" = {'filename': files ('xn.JPG'), open ("D:DOCSDAY mail /DRjpg.JPG",'rb'))} # explicitly set the file name values_upimg={"Content - Type"'multipart/form-data; boundary= "----WebKitFormBoundaryn5UouHKhfu8g2XNp"; "Content' Length"'331698; boundary= "----WebKitFormBoundaryn5UouHKhfu8g2XNp"; "Content - Disposition". "Image":'form-data; name=; boundary=----WebKitFormBoundaryn5UouHKhfu8g2XNp ; ', "content - type": "application/octet-stream; boundary=----WebKitFormBoundaryn5UouHKhfu8g2XNp; req_upimg}" = (url_upimg, files=files, data=values_upimg) data = json.loads (req_upimg.text) media_id=data['media_id'] print ("* * * has been obtaining materials required for ID. return token media_id def"), send_msg (token, media_id): " url= # send pictures access_token=?" +token values = {"touser": "@all", "toParty", "2", #*************** Department ****************** "msgtype": "image", "AgentID": 1000003, "image", "media_id": {media_id}, 0} "safe": data = json.dumps (values) req = (URL, data) print ("return results:" req.text, return req) while True: curren # print return information T_time = time.localtime (time.time) (if) ((current_time.tm_hour = = 8) and (current_time.tm_min = 13) and and (current_time.tm_sec = = 50)): (result_department_no, result_member_no) = (get_group_id) (token, media_id) = (upload_img) send_msg (token, media_id) time.sleep (1) 

is this:

is all the content of this article, I hope to help everyone to learn, I hope you will support a script.

This paper fixed link: | Script Home | +Copy Link

Article reprint please specify:Python3 implementation of the public number daily daily and pictures | Script Home

You may also be interested in these articles!