diff --git a/resources/messages_resource.py b/resources/messages_resource.py index 58d0b15..cc1e682 100644 --- a/resources/messages_resource.py +++ b/resources/messages_resource.py @@ -23,7 +23,7 @@ class MessagesResource(Resource): def post(self): msg = request.get_json() - logger.info(f"收到微信回调消息: {msg}") + logger.info(f"收到微信回调消息: {json.dumps(msg, separators=(',', ':'),ensure_ascii=False)}") type_name =msg.get("TypeName") app_id = msg.get("Appid") # token_id = "f828cb3c-1039-489f-b9ae-7494d1778a15" diff --git a/wechat/biz.py b/wechat/biz.py index 92ad90a..8409513 100644 --- a/wechat/biz.py +++ b/wechat/biz.py @@ -242,14 +242,14 @@ def send_video_message(wxchat:gewe_chat.GeWeChatCom, token_id, app_id, agent_wxi filename = os.path.basename(parsed_url.path) tmp_file_path = os.path.join(os.getcwd(),'tmp', filename) # 拼接完整路径 thumbnail_path=tmp_file_path.replace('.mp4','.jpg') - video_thumb_url,video_duration =utils.download_video_and_get_thumbnail(file_url,thumbnail_path) - - print(f'视频缩略图 {video_thumb_url} 时长 {video_duration}') if wxchat.forward_video_aeskey == '': + video_thumb_url,video_duration =utils.download_video_and_get_thumbnail(file_url,thumbnail_path) + print(f'视频缩略图 {video_thumb_url} 时长 {video_duration}') + ret,ret_msg,res = wxchat.post_video(token_id, app_id, t, file_url,video_thumb_url,video_duration) if ret==200: wxchat.forward_video_aeskey = res["aesKey"] - wxchat.forward_video_cdnvideourl = res["cdnVideoUrl"] + wxchat.forward_video_cdnvideourl = res["cdnThumbUrl"] wxchat.forward_video_length = res["length"] else: ret,ret_msg,res = wxchat.forward_video(token_id, app_id, t, wxchat.forward_video_aeskey, wxchat.forward_video_cdnvideourl, wxchat.forward_video_length) diff --git a/wechat/gewe_chat.py b/wechat/gewe_chat.py index e1b8a9d..708abb5 100644 --- a/wechat/gewe_chat.py +++ b/wechat/gewe_chat.py @@ -374,7 +374,7 @@ class GeWeChatCom: "toWxid": to_wxid, "videoUrl": video_url, "videoDuration":video_duration, - "videoThumbUrl":video_thumb_url + "thumbUrl":video_thumb_url } response = requests.post(url=api_url, headers=headers, data=json.dumps(data)) response_object = response.json() @@ -410,7 +410,7 @@ class GeWeChatCom: } response = requests.post(url=api_url, headers=headers, data=json.dumps(data)) response_object = response.json() - return response_object.get('data',None),response_object.get('ret',None),response_object.get('msg',None) + return response_object.get('ret',None),response_object.get('msg',None),response_object.get('data',None) def add_contacts(self,token_id:str,app_id:str,scene:int,option:int,v3:str,v4:str,content:str): api_url = f"{self.base_url}/v2/api/contacts/addContacts"