移动用户到指定分组

@param string $openid 用户ID,to_groupid 指定分组ID

@return bool.
10727
public function moveUser($openid, $to_groupid)
    {
        if (!is_numeric($to_groupid) || !is_string($openid)) {
            $this->setError('参数错误,用户ID格式不正确或组ID不是数字');

            return false;
        }

        $queryStr = ['openid' => $openid, 'to_groupid' => $to_groupid];

        $res = $this->_post('members/update', $queryStr);

        return $res;
    }
359993
public function getGroup($groupId)
    {
        static $groups = array();

        if (! isset($groups[$groupId])) {
            $groups[$groupId] = $this->_loadClass('Group', true, array($groupId));
    }

        return $groups[$groupId];
    }
588783
public function updateGroupUsers($uids, $gid) {
		if(is_array($uids)) {
			$uids = implode(',', $uids);
		}

		$query = WechatUser::find()->where("id in ($uids) and groupid <> $gid");
		$users = $query->all();
		$openids = ArrayHelper::getColumn($users, 'openid');

		if(!$openids) {
			return true;
		}

		$data = $this->getData('/cgi-bin/groups/members/batchupdate', [
			'access_token' => $this->getAccessToken(),
		], Json::encode([
			'openid_list' => $openids,
			'to_groupid' => $gid,
		]));

		$result = $this->errcode == 0;
		if($result) {
			foreach($users as $user) {
				if($user->group->updateCounters(['count' => -1])) {
					$user->groupid = $gid;
					if($user->save()) {
						$user->refresh();
						$user->group->updateCounters(['count' => 1]);
					}
				}
			}
		}

		return $result;
	}
863195
public function getUserInfo($openid)
    {
        if (!$this->access_token && !$this->getAccessToken()) {
            return false;
        }
        $result = Tools::httpGet(self::API_URL_PREFIX . self::USER_INFO_URL . "access_token={$this->access_token}&openid={$openid}");
        if ($result) {
            $json = json_decode($result, true);
            if (empty($json) || !empty($json['errcode'])) {
                $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
                $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容！';
                return $this->checkRetry(__FUNCTION__, func_get_args());
            }
            return $json;
        }
        return false;
    }
349068
public function getGroup ($groupID)
    {
        $groups = $this->getAllGroups();
        
        foreach ($groups as $group) {
            if ($group->getID() == $groupID) {
                return $group;
            }
        }
        
        return null;
    }
875016
public function get_user_group($open_id)
    {
        $url = self::API_DOMAIN . 'cgi-bin/groups/getid?access_token=' .$this->get_access_token();
        $xml = sprintf('{"openid":"%s"}', $open_id);
        $res = HttpCurl::post($url, $xml, 'json');
        // 异常处理: 获取时网络错误
        if ($res === false) {
            return Error::code('ERR_POST');
        }
        // 判断是否调用成功
        if (isset($res->groupid)) {
            return array(null, $res);
        } else {
            return array($res, null);
        }
    }
1344135
public function getMemberInfo($openId, $lang = 'zh_CN')
    {
        $result = $this->httpGet(self::WECHAT_MEMBER_INFO_URL . 'access_token=' . $this->getAccessToken(), [
            'openid' => $openId,
            'lang' => $lang
        ]);
        return !isset($result['errcode']) ? $result : false;
    }
687818
public function deleteGroup($groupId)
    {
        return $this->auth(function () use ($groupId) {
            return $this->http->postJson(
                $this->baseUrl . 'cgi-bin/groups/delete?access_token=' . $this->accessToken,
                json_encode(
                    [
                        'group' => [
                            'id' => $groupId,
                        ],
                    ],
                    JSON_UNESCAPED_UNICODE
                )
            );
        });
    }
839284
public function tryConditional($openid)
    {
        $url = "https://api.weixin.qq.com/cgi-bin/menu/trymatch?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, ['user_id' => $openid]);
    }
1243070
public function updateGroupMembers($groupid,$openid){
        if (!$this->access_token && !$this->checkAuth()) return false;
        $data = array(
                'openid'=>$openid,
                'to_groupid'=>$groupid
        );
        $result = $this->http_post(self::API_URL_PREFIX.self::GROUP_MEMBER_UPDATE_URL.'access_token='.$this->access_token,self::json_encode($data));
        if ($result)
        {
            $json = json_decode($result,true);
            if (!$json || !empty($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                return false;
            }
            return $json;
        }
        return false;
    }
98477
public function delete($id)
    {
        if (!is_numeric($id)) {
            $this->setError('参数错误,分组ID不是数字');

            return false;
        }

        $queryStr = [
            'group' => ['id' => $id],
        ];

        $res = $this->_post('delete', $queryStr);

        return $res;
    }
1079034
public function select(array $openids, string $lang = 'zh_CN')
    {
        return $this->httpPostJson('cgi-bin/user/info/batchget', [
            'user_list' => array_map(function ($openid) use ($lang) {
                return [
                    'openid' => $openid,
                    'lang' => $lang,
                ];
            }, $openids),
        ]);
    }
1126148
public function openid(string $deviceId)
    {
        $params = [
            'device_type' => $this->app['config']['device_type'],
            'device_id' => $deviceId,
        ];

        return $this->httpGet('device/get_openid', $params);
    }
620281
public function getGroup($groupId)
    {
        $result = $this->wechat->httpRaw(self::WECHAT_GROUP_ID_GET_PREFIX, [
            'group_id' => $groupId
        ], [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success' ? $result['groups_detail'] : false;
    }
1114354
public function getKFSession($openid){
	    if (!$this->access_token && !$this->checkAuth()) return false;
	    $result = $this->http_get(self::API_BASE_URL_PREFIX.self::CUSTOM_SESSION_GET .'access_token='.$this->access_token.'&openid='.$openid);
	    if ($result)
	    {
	        $json = json_decode($result,true);
	        if (!$json || !empty($json['errcode'])) {
	            $this->errCode = $json['errcode'];
	            $this->errMsg = $json['errmsg'];
	            return false;
	        }
	        return $json;
	    }
	    return false;
	}
569348
public function updateMemberGroup($openId, $toGroupId)
    {
        $result = $this->httpRaw(self::WECHAT_MEMBER_GROUP_UPDATE_URL . 'access_token=' . $this->getAccessToken(), [
            'openid' => $openId,
            'to_groupid' => $toGroupId
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok';
    }
464861
public function isAttention($openid = '') {
        try {
            $access_token = $this->getAccessToken();
            #设置URL地址
            $url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=$access_token&openid=$openid&lang=zh_CN";
            #提交数据
            $res = to_array($this->httpGet($url));
            if (isset($res['subscribe'])) {
                return $res;
            } else {
                throw new Exception($res['errmsg'], $res['errcode']);
            }
        } catch (Exception $e) {
            debug::exception($e);
        }
    }