Esempio n. 1
0
def get_chat_token(token_type, user_info):
    result = {'code': 1, 'msg': 'ok'}

    nonce = uniqid()
    try:
        if token_type == 1:
            token_id = 'buyer' + limter + str(
                user_info.buyer_id) + limter + user_info.account
        elif token_type == 2:
            token_id = 'shop' + limter + str(
                user_info.shop_id) + limter + user_info.account

        api = ApiClient()
        token = api.call_api(action="/user/getToken",
                             params={
                                 "userId": token_id,
                                 "name": user_info.account,
                                 "portraitUri": "p1"
                             })

        result['token'] = token
    except Exception, e:
        current_app.logger.exception(e)
        result['code'] = 1
        result['msg'] = e.message