yzk_wechat_event/apps/jqr/ksy_http.py

46 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import requests
class Http(object):
BASE_URL = 'http://114.215.169.94:7035'
@classmethod
def get_new_user_msg(cls, corpid, userid, external_userid, uid=None):
uid = uid or 3
url = f'{cls.BASE_URL}/api/newusermsg/getnewusermsg'
params = {
'corpId': corpid,
'userId': userid,
'externalUserId': external_userid,
'uId': uid,
}
res = requests.get(url, params=params)
if res.status_code == 200:
return True, res.json().get('data')
return False, None
# api/newusermsg/getkeywordreplymsg?corpId=&userId=&uId=&externalUserId=&sendType=&content=
@classmethod
def get_keyword_reply_msg(cls, corpid, userid, external_userid, uid=None, send_type=0, content=None):
# sendType 0 私聊1 群聊
uid = uid or 3
url = f'{cls.BASE_URL}/api/newusermsg/getkeywordreplymsg'
params = {
'corpId': corpid,
'userId': userid,
'externalUserId': external_userid,
'uId': uid,
'sendType': send_type,
'content': content,
}
res = requests.get(url, params=params)
if res.status_code == 200:
return True, res.json().get('data')
return False, None
if __name__ == '__main__':
success, data = Http.get_new_user_msg('ww056d00fac4950f54', 'agent-Wang', 'wmy1VmQgAAd1BJaEHCrdOttQop7gg8Rg')
print(success)
print(data)