获取所有的用户openid列表 详情请参考 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840 :return: 返回一个迭代器,可以用for进行循环,得到openid 使用示例:: from wechatpy import WeChatClient client = WeChatClient('appid', 'secret') for openid
(self, first_user_id=None)
| 63 | ) |
| 64 | |
| 65 | def iter_followers(self, first_user_id=None): |
| 66 | """ |
| 67 | 获取所有的用户openid列表 |
| 68 | |
| 69 | 详情请参考 |
| 70 | https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840 |
| 71 | |
| 72 | :return: 返回一个迭代器,可以用for进行循环,得到openid |
| 73 | |
| 74 | 使用示例:: |
| 75 | |
| 76 | from wechatpy import WeChatClient |
| 77 | |
| 78 | client = WeChatClient('appid', 'secret') |
| 79 | for openid in client.user.iter_followers(): |
| 80 | print(openid) |
| 81 | |
| 82 | """ |
| 83 | while True: |
| 84 | follower_data = self.get_followers(first_user_id) |
| 85 | first_user_id = follower_data["next_openid"] |
| 86 | # 微信有个bug(或者叫feature),没有下一页,也返回next_openid这个字段 |
| 87 | # 所以要通过total_count和data的长度比较判断(比较麻烦,并且不稳定) |
| 88 | # 或者获得结果前先判断data是否存在 |
| 89 | if 'data' not in follower_data: |
| 90 | return |
| 91 | for openid in follower_data['data']['openid']: |
| 92 | yield openid |
| 93 | if not first_user_id: |
| 94 | return |
| 95 | |
| 96 | def update_remark(self, user_id, remark): |
| 97 | """ |