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 = "http://e.vhall.com/api/vhallapi/v2/user/get-user-id"  # 获取微吼用户ID
        self.wh_add_url = "http://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)

其他接口微吼api文档:

http://www.vhall.com/saas/doc/9.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值