|
|
@@ -363,7 +363,116 @@ class GeWeService: |
|
|
|
async with session.post(api_url, headers=headers, json=data) as response: |
|
|
|
response_object = await response.json() |
|
|
|
return response_object.get('ret', None), response_object.get('msg', None), response_object.get('data', None) |
|
|
|
|
|
|
|
async def post_mini_app_aysnc(self, token_id, app_id,to_wxid, mini_app_id,display_name,page_path,cover_img_url,title,user_name): |
|
|
|
''' |
|
|
|
发送小程序消息 |
|
|
|
''' |
|
|
|
api_url = f"{self.base_url}/v2/api/message/postMiniApp" |
|
|
|
headers = { |
|
|
|
'X-GEWE-TOKEN': token_id, |
|
|
|
'Content-Type': 'application/json' |
|
|
|
} |
|
|
|
data = { |
|
|
|
"appId": app_id, |
|
|
|
"toWxid": to_wxid, |
|
|
|
"miniAppId": mini_app_id, |
|
|
|
"displayName": display_name, |
|
|
|
"pagePath": page_path, |
|
|
|
"coverImgUrl": cover_img_url, |
|
|
|
"title": title, |
|
|
|
"userName": user_name |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async with aiohttp.ClientSession() as session: |
|
|
|
async with session.post(api_url, headers=headers, json=data) as response: |
|
|
|
response_object = await response.json() |
|
|
|
return response_object.get('ret', None), response_object.get('msg', None), response_object.get('data', None) |
|
|
|
|
|
|
|
async def post_link_async(self,token_id, app_id,to_wxid, title,desc,link_url,thumb_url): |
|
|
|
''' |
|
|
|
发送链接消息 |
|
|
|
''' |
|
|
|
api_url = f"{self.base_url}/v2/api/message/postLink" |
|
|
|
headers = { |
|
|
|
'X-GEWE-TOKEN': token_id, |
|
|
|
'Content-Type': 'application/json' |
|
|
|
} |
|
|
|
data = { |
|
|
|
"appId": app_id, |
|
|
|
"toWxid": to_wxid, |
|
|
|
"title": title, |
|
|
|
"desc": desc, |
|
|
|
"linkUrl": link_url, |
|
|
|
"thumbUrl": thumb_url |
|
|
|
} |
|
|
|
async with aiohttp.ClientSession() as session: |
|
|
|
async with session.post(api_url, headers=headers, json=data) as response: |
|
|
|
response_object = await response.json() |
|
|
|
return response_object.get('ret', None), response_object.get('msg', None), response_object.get('data', None) |
|
|
|
|
|
|
|
async def post_name_card_async(self,token_id, app_id,to_wxid,nickName,nameCard_wxid): |
|
|
|
''' |
|
|
|
发送名片消息 |
|
|
|
''' |
|
|
|
api_url = f"{self.base_url}/v2/api/message/postNameCard" |
|
|
|
headers = { |
|
|
|
'X-GEWE-TOKEN': token_id, |
|
|
|
'Content-Type': 'application/json' |
|
|
|
} |
|
|
|
data = { |
|
|
|
"appId": app_id, |
|
|
|
"toWxid": to_wxid, |
|
|
|
"nickName": nickName, |
|
|
|
"nameCardWxid": nameCard_wxid |
|
|
|
} |
|
|
|
async with aiohttp.ClientSession() as session: |
|
|
|
async with session.post(api_url, headers=headers, json=data) as response: |
|
|
|
response_object = await response.json() |
|
|
|
return response_object.get('ret', None), response_object.get('msg', None), response_object.get('data', None) |
|
|
|
|
|
|
|
# 发送emoji消息 |
|
|
|
async def post_emoji_async(self,token_id, app_id,to_wxid,emoji_md5,emoji_size): |
|
|
|
api_url = f"{self.base_url}/v2/api/message/postEmoji" |
|
|
|
headers = { |
|
|
|
'X-GEWE-TOKEN': token_id, |
|
|
|
'Content-Type': 'application/json' |
|
|
|
} |
|
|
|
data = { |
|
|
|
"appId": app_id, |
|
|
|
"toWxid": to_wxid, |
|
|
|
"emojiMd5": emoji_md5, |
|
|
|
"emojiSize": emoji_size |
|
|
|
} |
|
|
|
async with aiohttp.ClientSession() as session: |
|
|
|
async with session.post(api_url, headers=headers, json=data) as response: |
|
|
|
response_object = await response.json() |
|
|
|
return response_object.get('ret', None), response_object.get('msg', None), response_object.get('data', None) |
|
|
|
|
|
|
|
# 发送appmsg消息 |
|
|
|
async def post_app_msg_async(self,token_id, app_id,to_wxid,appmsg): |
|
|
|
''' |
|
|
|
本接口可用于发送所有包含节点的消息,例如:音乐分享、视频号、引用消息等等 |
|
|
|
''' |
|
|
|
api_url = f"{self.base_url}/v2/api/message/postAppMsg" |
|
|
|
headers = { |
|
|
|
'X-GEWE-TOKEN': token_id, |
|
|
|
'Content-Type': 'application/json' |
|
|
|
} |
|
|
|
data = { |
|
|
|
"appId": app_id, |
|
|
|
"toWxid": to_wxid, |
|
|
|
"appmsg": appmsg |
|
|
|
} |
|
|
|
|
|
|
|
async with aiohttp.ClientSession() as session: |
|
|
|
async with session.post(api_url, headers=headers, json=data) as response: |
|
|
|
response_object = await response.json() |
|
|
|
return response_object.get('ret', None), response_object.get('msg', None), response_object.get('data', None) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def forward_image_async(self, token_id, app_id, to_wxid, aeskey, cdnthumburl, cdnthumblength, cdnthumbheight, cdnthumbwidth, length, md5): |
|
|
|
|
|
|
|
api_url = f"{self.base_url}/v2/api/message/forwardImage" |
|
|
@@ -397,6 +506,58 @@ class GeWeService: |
|
|
|
response_object = await response.json() |
|
|
|
return response_object.get('ret', None), response_object.get('msg', None), response_object.get('data', None) |
|
|
|
|
|
|
|
# 转发文件 |
|
|
|
async def forward_file_async(self, token_id, app_id, to_wxid, xml): |
|
|
|
api_url = f"{self.base_url}/v2/api/message/forwardFile" |
|
|
|
headers = { |
|
|
|
'X-GEWE-TOKEN': token_id, |
|
|
|
'Content-Type': 'application/json' |
|
|
|
} |
|
|
|
data = { |
|
|
|
"appId": app_id, |
|
|
|
"toWxid": to_wxid, |
|
|
|
"xml": xml |
|
|
|
} |
|
|
|
async with aiohttp.ClientSession() as session: |
|
|
|
async with session.post(api_url, headers=headers, json=data) as response: |
|
|
|
response_object = await response.json() |
|
|
|
return response_object.get('ret', None), response_object.get('msg', None), response_object.get('data', None) |
|
|
|
|
|
|
|
# 转发链接 |
|
|
|
async def forward_link_async(self, token_id, app_id, to_wxid, xml): |
|
|
|
api_url = f"{self.base_url}/v2/api/message/forwardLink" |
|
|
|
headers = { |
|
|
|
'X-GEWE-TOKEN': token_id, |
|
|
|
'Content-Type': 'application/json' |
|
|
|
} |
|
|
|
data = { |
|
|
|
"appId": app_id, |
|
|
|
"toWxid": to_wxid, |
|
|
|
"xml": xml |
|
|
|
} |
|
|
|
async with aiohttp.ClientSession() as session: |
|
|
|
async with session.post(api_url, headers, json=data) as response: |
|
|
|
response_object = await response.json() |
|
|
|
return response_object.get('ret', None), response_object.get('msg', None), response_object.get('data', None) |
|
|
|
|
|
|
|
# 转发小程序 |
|
|
|
async def forward_mini_app_async(self, token_id, app_id, to_wxid, xml,cover_img_url): |
|
|
|
api_url = f"{self.base_url}/v2/api/message/forwardMiniApp" |
|
|
|
headers = { |
|
|
|
'X-GEWE-TOKEN': token_id, |
|
|
|
'Content-Type': 'application/json' |
|
|
|
} |
|
|
|
data = { |
|
|
|
"appId": app_id, |
|
|
|
"toWxid": to_wxid, |
|
|
|
"xml": xml, |
|
|
|
"coverImgUrl":cover_img_url |
|
|
|
} |
|
|
|
async with aiohttp.ClientSession() as session: |
|
|
|
async with session.post(api_url, headers=headers, json=data) as response: |
|
|
|
response_object = await response.json() |
|
|
|
return response_object.get('ret', None), response_object.get('msg', None), response_object.get('data', None) |
|
|
|
|
|
|
|
async def add_contacts_async(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" |
|
|
|
headers = { |
|
|
@@ -434,6 +595,8 @@ class GeWeService: |
|
|
|
response_object = await response.json() |
|
|
|
return response_object.get('ret', None), response_object.get('msg', None), response_object.get('data', None) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
############################### 下载模块 ############################### |
|
|
|
async def download_audio_msg_async(self, token_id: str, app_id: str, msg_id: int, xml: str): |
|
|
|
data = { |
|
|
@@ -844,20 +1007,6 @@ class GeWeService: |
|
|
|
response_object = await response.json() |
|
|
|
return response_object.get('ret', None), response_object.get('msg', None), response_object.get('data', None) |
|
|
|
|
|
|
|
# async def label_list_async(self, token_id, app_id): |
|
|
|
# api_url = f"{self.base_url}/v2/api/label/list" |
|
|
|
# headers = { |
|
|
|
# 'X-GEWE-TOKEN': token_id, |
|
|
|
# 'Content-Type': 'application/json' |
|
|
|
# } |
|
|
|
# data = { |
|
|
|
# "appId": app_id, |
|
|
|
# } |
|
|
|
# async with aiohttp.ClientSession() as session: |
|
|
|
# async with session.post(api_url, headers=headers, json=data) as response: |
|
|
|
# response_object = await response.json() |
|
|
|
# return response_object.get('ret', None), response_object.get('msg', None), response_object.get('data', None) |
|
|
|
|
|
|
|
async def label_list_async(self, token_id, app_id): |
|
|
|
api_url = f"{self.base_url}/v2/api/label/list" |
|
|
|
headers = { |
|
|
|