def openid_to_commid(self, openid_list): url = 'http://%s:%s/innerapi/acctapi/transid/openid_to_commid?appname=%s' % ( self.ip, self.port, self.appname) data = {} data['openid_list'] = openid_list tmp = open_url_json(url=url, data=data) if tmp and isinstance(tmp, dict) and tmp.has_key("commid_list"): logger.info('get commid_list success.') return tmp["commid_list"] else: logger.warn('[WARN]get commid_list failed.') return ''
def _convert_openid(self, openid_list): from lib.httptool import open_url_json send_data = {} lp_appid = 'wx9ce8f64a4c9b3308' send_data['target_appid'] = lp_appid send_data['openid_list'] = openid_list tmp = open_url_json(url='http://%s/weixin/openid/convert' % Domain, data=send_data) if not (tmp and isinstance(tmp, dict) and tmp.get("data")): logger.error('convert uid to lpuid error, uid:%s lp_appid:%s' % (uid, lp_appid)) return None return tmp.get('data')
def _convert_weinxin_openid_arr(openid_arr=[]): if len(openid_arr): from lib.httptool import open_url_json data = {} data['target_appid'] = 'wx3566ceb82d2e0f2d' data['openid_list'] = openid_arr tmp = open_url_json(url='http://%s/weixin/openid/convert' % Domain, data=data) if not (tmp and isinstance(tmp, dict) and tmp.get("data")): logger.error('convert uid to lpuid error, uid:%s lp_appid:%s' % (openid_arr, 'wx3566ceb82d2e0f2d')) return None openid_map = tmp.get('data') if not (openid_map and len(openid_map)): logger.error('weixin_openid_to_openid return null, return None') return None logger.info('convert to newbridge openid finish, result:%s' % openid_map) return openid_map
def openid_to_openid(self, openid_list, target_appid): url = 'http://%s:%s/innerapi/acctapi/transid/openid_to_openid?appname=%s' % ( self.ip, self.port, self.appname) data = {} data['target_appid'] = target_appid data['openid_list'] = openid_list logger.info('post url:%s' % url) logger.info('post data:%s' % data) tmp = open_url_json(url=url, data=data) if tmp and isinstance(tmp, dict) and tmp.has_key("openid_list") and len( tmp["openid_list"]): logger.info('get openid_list success.') openid_map = {} for item in tmp["openid_list"]: openid_map[item['source_openid']] = item['target_openid'] return openid_map else: logger.warn('[WARN]get openid_list failed.') logger.warn(tmp) return ''