From c194f5cf6b92fbb74a9160455ad10f8f4bce9b79 Mon Sep 17 00:00:00 2001 From: 3288588344 <127068117+3288588344@users.noreply.github.com> Date: Thu, 23 Jan 2025 19:21:40 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E5=A5=BD=E5=AE=9D=E8=B4=9D.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 好宝贝.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/好宝贝.py b/好宝贝.py index 91ee460..8d3e4eb 100644 --- a/好宝贝.py +++ b/好宝贝.py @@ -20,19 +20,30 @@ push_content = 'TL库\n\n' wxapp_token = 'AT_aTsJ*********' # wxpusher的APPToken def wxpusher_send(): + """ + 发送消息到wxpusher + """ headers = {'Content-Type': 'application/json;charset=utf-8'} data = { "appToken": wxapp_token, - "uids": [f"{push_token}"], + "uids": [push_token], "topicIds": [], "summary": push_title, "content": push_content, "contentType": 1, "verifyPay": False } - json_data = json.dumps(data) - response = requests.post('https://wxpusher.zjiecode.com/api/send/message', headers=headers, data=json_data) - print(response.text, "\n") + + try: + response = requests.post('https://wxpusher.zjiecode.com/api/send/message', headers=headers, data=json.dumps(data)) + + # 获取响应的 JSON 数据 + response_json = response.json() + + print(f"wxpusher 推送: {response_json.get('msg', '没有返回 msg 字段')}") + + except requests.exceptions.RequestException as e: + print(f"wxpusher 推送失败: {e}") # 获取公告信息 def get_announcement():