阅读背景:

python对接微吼_一个小角落

来源:互联网 


class AccountSync(object):
    def __init__(self):
      
        # 微吼
        self.auth_type = 1  # 授权类型,1为验证帐号和密码(目前只通过帐号和密码验证)
        self.account = 'xxx'  # auth_type为1时为必填项,用于登录e.vhall.com的帐号,是在“帐号设置”页面里查找到的“帐号”
        self.password = 'xxxx'  # auth_type为1时为必填项,用于登录e.vhall.com的密码,用于登录的密码
        self.wh_find_url = "https://e.vhall.com/api/vhallapi/v2/user/get-user-id"  # 获取微吼用户ID
        self.wh_add_url = "https://e.vhall.com/api/vhallapi/v2/user/register"  # 创建微吼用户

    # 添加微吼用户
    def set_wh_user(self, user_list):
        if user_list:
            for user in user_list:
                username = user['name_']
                password = user['password_']
                body = {
                    "third_user_id": username,
                    "auth_type": self.auth_type,
                    "account": self.account,
                    "password": self.password
                }
                find_res = hx_request.post(url=self.wh_find_url, headers=self.headers, parameters=body)
                if find_res.data['code'] != '200':  # 微吼没有该用户
                    logger.error('微吼没有用户: %s' % user)
                    body['pass'] = password
                    response = hx_request.post(url=self.wh_add_url, headers=self.headers, parameters=body)
                    if response.data['code'] != 200:  # 增加微吼用户失败
                        logger.error('增加微吼用户失败: %s, error_msg:%s' % (user, response.data['msg']))
                    if response.data['code'] == 200:  # 增加微吼用户成功
                        logger.info('增加微吼用户成功: %s' % user)

class AccountSync(object):
    def __init__(s



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: