From a6bc311651d1ac763a9701d777d2d54ad66d0b27 Mon Sep 17 00:00:00 2001 From: p39718465 <569659537@qq.com> Date: Thu, 31 Aug 2023 20:07:28 +0800 Subject: [PATCH] Delete 'src/wechat.py' --- src/wechat.py | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 src/wechat.py diff --git a/src/wechat.py b/src/wechat.py deleted file mode 100644 index c3dc32e..0000000 --- a/src/wechat.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/python3 -#_*_coding:utf-8 _*_ -import urllib.request -import json -import sys - -def gettoken(corpid,corpsecret): - gettoken_url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=' + corpid + '&corpsecret=' + corpsecret - print (gettoken_url) - try: - token_file = urllib.request.urlopen(gettoken_url) - except urllib.error.HTTPError as e: - print (e.code) - print (e.read().decode("utf8")) - sys.exit() - token_data = token_file.read().decode('utf-8') - token_json = json.loads(token_data) - token_json.keys() - token = token_json['access_token'] - return token - -def senddata(access_token,user,subject,content): - - send_url = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=' + access_token - send_values = { - "touser":"$1", - "toparty":"2", - "msgtype":"text", - "agentid":"1000002", - "text":{ - "content":subject + '\n' + content - }, - "safe":"0" - } -# send_data = json.dumps(send_values, ensure_ascii=False) - send_data = json.dumps(send_values, ensure_ascii=False).encode('utf-8') - send_request = urllib.request.Request(send_url, send_data) - response = urllib.request.urlopen(send_request) - msg = response.read() - print ("returned value : " + str(msg)) - - -if __name__ == '__main__': - user = str(sys.argv[1]) - subject = str(sys.argv[2]) - content = str(sys.argv[3]) - - corpid = 'ww07d639f4db857c16' - corpsecret = 'gTBUceozR5SQLStDeEdKN2bWJYLF2jlzk4zoCn_8I34' - accesstoken = gettoken(corpid,corpsecret) - senddata(accesstoken,user,subject,content) \ No newline at end of file