+
|
|
8
|
+from utils.redis.rkeys import SUBSCRIBE_USERINFO_LIST
|
|
|
9
|
+
|
|
|
10
|
+
|
|
|
11
|
+r1 = connector(settings.REDIS.get('db1', {}))
|
|
|
12
|
+
|
|
|
13
|
+
|
|
|
14
|
+WECHAT = settings.WECHAT
|
|
|
15
|
+
|
|
|
16
|
+
|
|
|
17
|
+def fetch_users_func(authorizer_appid, infos):
|
|
|
18
|
+ print authorizer_appid, infos
|
|
|
19
|
+ openids = infos.get('data', {}).get('openid', [])
|
|
|
20
|
+ for openid in openids:
|
|
|
21
|
+ r1.rpushjson(SUBSCRIBE_USERINFO_LIST % authorizer_appid, {
|
|
|
22
|
+ 'brand_id': authorizer_appid,
|
|
|
23
|
+ 'openid': openid
|
|
|
24
|
+ })
|
|
|
25
|
+
|
|
|
26
|
+
|
|
|
27
|
+def fetch_all_users(brand_id):
|
|
|
28
|
+ wxcfg = WECHAT.get('{}:JSAPI'.format(brand_id), {})
|
|
|
29
|
+
|
|
|
30
|
+ appid = wxcfg.get('appID')
|
|
|
31
|
+ secret = wxcfg.get('appsecret')
|
|
|
32
|
+
|
|
|
33
|
+ get_all_users(appid=appid, secret=secret, storage=RedisStorage(r1), authorizer_appid=brand_id, users_func=fetch_users_func)
|