R/getUserList.R

Defines functions getUserList

getUserList <- function(obj, nextid = "", ...) {
	if (!inherits(obj, "weixin")) stop("A weixin object is required!")
	requestURL <- "https://api.weixin.qq.com/cgi-bin/user/get"
	s0 <- paste0(requestURL, "?access_token=", obj$oauthToken, "&next_openid=", nextid)
	
	u0 <- .getURL(s0, ...)
	OUT <- u0$data$openid
	if (!nzchar(nextid) && u0$total > u0$count) {
		tmp.nextid <- u0$next_openid
		while (length(OUT) < u0$total) {
			s1 <- paste0(requestURL, "?access_token=", obj$oauthToken, "&next_openid=", tmp.nextid)
			u1 <- fromJSON(getURL(s1, ...))
			tmp.nextid <- u1$next_openid
			OUT <- c(OUT, u1$data$openid)
		}
	}
	return(OUT)
}
Lchiffon/Rweixin documentation built on June 14, 2022, 3:04 p.m.