File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ class WechatUser extends Common {
1717 const USER_GET_URL = '/user/get? ' ;
1818 /* 获取粉丝信息 */
1919 const USER_INFO_URL = '/user/info? ' ;
20+ /* 批量获取粉丝信息 */
21+ const USER_BATCH_INFO_URL = '/user/info/batchget ' ;
2022 /* 更新粉丝标注 */
2123 const USER_UPDATEREMARK_URL = '/user/info/updateremark? ' ;
2224
@@ -104,6 +106,33 @@ public function getUserInfo($openid) {
104106 return false ;
105107 }
106108
109+ /**
110+ * 批量获取用户基本信息
111+ * @param array $openids 用户oepnid列表(最多支持100个openid)
112+ * @param string $lang 指定返回语言
113+ * @return bool|mixed
114+ */
115+ public function getUserBatchInfo (array $ openids , $ lang = 'zh-CN ' ) {
116+ if (!$ this ->access_token && !$ this ->getAccessToken ()) {
117+ return false ;
118+ }
119+ $ data = array ();
120+ foreach ($ openids as $ openid ) {
121+ $ data [] = array ('openid ' => $ openid , 'lang ' => $ lang );
122+ }
123+ $ result = Tools::httpPost (self ::API_URL_PREFIX . self ::USER_BATCH_INFO_URL . "access_token= {$ this ->access_token }" , $ data );
124+ if ($ result ) {
125+ $ json = json_decode ($ result , true );
126+ if (isset ($ json ['errcode ' ]) && !isset ($ json ['user_info_list ' ])) {
127+ $ this ->errCode = $ json ['errcode ' ];
128+ $ this ->errMsg = $ json ['errmsg ' ];
129+ return $ this ->checkRetry (__FUNCTION__ , func_get_args ());
130+ }
131+ return $ json ['user_info_list ' ];
132+ }
133+ return false ;
134+ }
135+
107136 /**
108137 * 设置粉丝备注名
109138 * @param string $openid
You can’t perform that action at this time.
0 commit comments